From 409b1b2bf3043b8aca226db39505df3ba9aab937 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sun, 30 Apr 2023 12:45:18 -0400 Subject: Ensure test cases are testing the command output --- tests/conftest.py | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'tests/conftest.py') 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) -- cgit v1.2.3