blob: f3b94272a11fe3a2861e300a0734ee962db88fac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import subprocess
import uuid
from pathlib import Path
from typing import Callable
import pytest
from poetry.factory import Factory
from poetry.poetry import Poetry
@pytest.fixture
def execute_task() -> Callable[[str], subprocess.Popen]:
def _execute_task(args: str):
process = subprocess.Popen(
f"poetry task {args}",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
)
process.wait()
return process
return _execute_task
@pytest.fixture
def project_factory(tmp_path: Path):
def _factory(pyproject_content: str) -> Poetry:
project_dir = tmp_path / f"poetry-fixture-{uuid.uuid4()}"
project_dir.mkdir(parents=True, exist_ok=True)
with project_dir.joinpath("pyproject.toml").open("w", encoding="utf-8") as f:
f.write(pyproject_content)
poetry = Factory().create_poetry(project_dir)
return poetry
return _factory
|