From 4efa9978af4a1ea70d6e9b7e124943ffc62ab5a1 Mon Sep 17 00:00:00 2001 From: Andrzej Klajnert Date: Tue, 19 Mar 2024 14:31:51 +0100 Subject: [PATCH 1/6] Fix CI --- tests/test_asyncio.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index ab8f80e..6f4b301 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -10,23 +10,14 @@ PYTHON = sys.executable - -@pytest.fixture(autouse=True) -def event_loop(request): +@pytest.fixture() +def event_loop_policy(request): if sys.platform.startswith("win"): if request.node.name.startswith("test_invalid_event_loop"): - loop = asyncio.SelectorEventLoop() + return asyncio.WindowsSelectorEventLoopPolicy() else: - loop = asyncio.ProactorEventLoop() - elif sys.version_info.minor < 7: - loop = asyncio.get_event_loop() - else: - try: - loop = asyncio.get_running_loop() - except RuntimeError: - loop = asyncio.new_event_loop() - yield loop - loop.close() + return asyncio.WindowsProactorEventLoopPolicy() + return asyncio.DefaultEventLoopPolicy() @pytest.mark.asyncio From 557197636c7dd3e5914330b7b50541a67f7a24de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:33:08 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_asyncio.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index 6f4b301..27a20e2 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -10,6 +10,7 @@ PYTHON = sys.executable + @pytest.fixture() def event_loop_policy(request): if sys.platform.startswith("win"): From d034118da1a8d1723b36e958847bf6b4d44e72ef Mon Sep 17 00:00:00 2001 From: Andrzej Klajnert Date: Tue, 19 Mar 2024 15:45:33 +0100 Subject: [PATCH 3/6] Fixed mypy --- pytest_subprocess/utils.py | 6 +++++- setup.cfg | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pytest_subprocess/utils.py b/pytest_subprocess/utils.py index 65e1975..86caa8b 100644 --- a/pytest_subprocess/utils.py +++ b/pytest_subprocess/utils.py @@ -8,6 +8,10 @@ from typing import Sequence from typing import Tuple from typing import Union +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from .types import COMMAND ARGUMENT = Union[str, "Any", os.PathLike] @@ -31,7 +35,7 @@ class Command: def __init__( self, - command: Union[Sequence[ARGUMENT], str], + command: "COMMAND", ): if isinstance(command, str): command = tuple(command.split(" ")) diff --git a/setup.cfg b/setup.cfg index c9da5a2..ca4dac3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ ignore = E231,W503 max-line-length = 89 [mypy] -python_version = 3.6 +python_version = 3.8 warn_return_any = True warn_unused_configs = True disallow_untyped_defs = True From 99fc0ba04582a1493e9ad93be1cde0167c531dc3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:47:38 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pytest_subprocess/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest_subprocess/utils.py b/pytest_subprocess/utils.py index 86caa8b..eece249 100644 --- a/pytest_subprocess/utils.py +++ b/pytest_subprocess/utils.py @@ -7,8 +7,8 @@ from typing import Optional from typing import Sequence from typing import Tuple -from typing import Union from typing import TYPE_CHECKING +from typing import Union if TYPE_CHECKING: from .types import COMMAND From 0f6b2b268292ba79b212bfdf9558c26a984e935b Mon Sep 17 00:00:00 2001 From: Andrzej Klajnert Date: Mon, 25 Mar 2024 15:23:52 +0100 Subject: [PATCH 5/6] Fixed tests on Windows < 3.8 --- tests/test_asyncio.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index 27a20e2..c2036bf 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -20,6 +20,13 @@ def event_loop_policy(request): return asyncio.WindowsProactorEventLoopPolicy() return asyncio.DefaultEventLoopPolicy() +if sys.platform.startswith("win") and sys.version_info < (3, 8): + @pytest.fixture(autouse=True) + def event_loop(request, event_loop_policy): + loop = event_loop_policy.new_event_loop() + yield loop + loop.close() + @pytest.mark.asyncio @pytest.mark.parametrize("mode", ["shell", "exec"]) From 6f6bd66619f9354b7d60da6945ede7532551af5b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:24:27 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_asyncio.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index c2036bf..7d4cafd 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -20,7 +20,9 @@ def event_loop_policy(request): return asyncio.WindowsProactorEventLoopPolicy() return asyncio.DefaultEventLoopPolicy() + if sys.platform.startswith("win") and sys.version_info < (3, 8): + @pytest.fixture(autouse=True) def event_loop(request, event_loop_policy): loop = event_loop_policy.new_event_loop()