Skip to content

Commit

Permalink
Fix CI (#148)
Browse files Browse the repository at this point in the history
* Fix CI

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed mypy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed tests on Windows < 3.8

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
aklajnert and pre-commit-ci[bot] authored Mar 25, 2024
1 parent 4187ef2 commit 5572283
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 5 additions & 1 deletion pytest_subprocess/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import TYPE_CHECKING
from typing import Union

if TYPE_CHECKING:
from .types import COMMAND

ARGUMENT = Union[str, "Any", os.PathLike]


Expand All @@ -31,7 +35,7 @@ class Command:

def __init__(
self,
command: Union[Sequence[ARGUMENT], str],
command: "COMMAND",
):
if isinstance(command, str):
command = tuple(command.split(" "))
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions tests/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
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()


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
Expand Down

0 comments on commit 5572283

Please # to comment.