aboutsummaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2023-04-30 12:45:18 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2023-04-30 12:45:18 -0400
commit409b1b2bf3043b8aca226db39505df3ba9aab937 (patch)
treef83a437faf4f16a92585685153d41aa5d356c98b /tests/conftest.py
parentUse variable in `test` task (diff)
downloadpoetry-plugin-taskipy2-409b1b2bf3043b8aca226db39505df3ba9aab937.zip
Ensure test cases are testing the command output
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py39
1 files changed, 13 insertions, 26 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index d75cfc1..10ae86c 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,45 +1,32 @@
+import uuid
+import subprocess
from pathlib import Path
from typing import Callable
import pytest
-from cleo.io.null_io import NullIO
-from cleo.testers.command_tester import CommandTester
-from poetry.console.application import Application as PoetryApplication
from poetry.factory import Factory
from poetry.poetry import Poetry
@pytest.fixture
-def command_tester_factory() -> Callable[[str], CommandTester]:
- def _tester(command: str) -> CommandTester:
- app = PoetryApplication()
- app._load_plugins(NullIO())
- cmd = app.find(command)
- tester = CommandTester(cmd)
- return tester
-
- return _tester
-
-
-@pytest.fixture
-def execute_task(
- command_tester_factory: Callable[[str], CommandTester]
-) -> Callable[[str], CommandTester]:
+def execute_task() -> Callable[[str], subprocess.Popen]:
def _execute_task(args: str):
- tester = command_tester_factory("task")
- tester.execute(args=args)
- return tester
+ 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(
- name: str,
- pyproject_content: str,
- ) -> Poetry:
- project_dir = tmp_path / f"poetry-fixture-{name}"
+ 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)