Skip to content

Commit

Permalink
[test] Remove pytest-trio from test dependencies.
Browse files Browse the repository at this point in the history
trio v0.22 deprecated trio.MultiError. This adjustment requires at least pytest-trio v0.8.0, [0] which, in turn, depends on pytest>=7.2. Pytest-asyncio currently supports pytest>=7.0. Therefore, we either need to juggle with the constraints in the pytest-min test environment or remove the pytest-trio dependency entirely.

I opted for the latter. Pytest-asyncio should be compatible with other plugins, but it should not be responsible to test that compatibility. If every pytest plugin wrote tests against other plugins, we ended up in dependency hell and a lot of work would be done multiple times.

There's a dedicated section in pytest for testing plugin integration. This is the right place to do it.

[0] https://pytest-trio.readthedocs.io/en/v0.8.0/history.html#misc

Signed-off-by: Michael Seifert <[email protected]>
  • Loading branch information
seifertm committed Nov 8, 2023
1 parent e55317a commit 973eaa4
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 55 deletions.
11 changes: 1 addition & 10 deletions dependencies/default/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
async-generator==1.10
attrs==23.1.0
coverage==7.3.2
exceptiongroup==1.1.3
flaky==3.7.0
hypothesis==6.88.3
idna==3.4
importlib-metadata==6.8.0
iniconfig==2.0.0
mypy==1.6.1
mypy-extensions==1.0.0
outcome==1.3.0.post0
packaging==23.2
pluggy==1.3.0
pyparsing==3.1.1
pytest==7.4.3
pytest-trio==0.8.0
sniffio==1.3.0
sortedcontainers==2.4.0
tomli==2.0.1
trio==0.23.1
typed-ast==1.5.5
zipp==3.17.0
typing_extensions==4.8.0
37 changes: 20 additions & 17 deletions dependencies/pytest-min/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
argcomplete==2.0.0
attrs==22.1.0
certifi==2022.9.24
charset-normalizer==2.1.1
elementpath==3.0.2
exceptiongroup==1.0.0rc9
hypothesis==6.56.3
argcomplete==3.1.2
attrs==23.1.0
certifi==2023.7.22
charset-normalizer==3.3.1
coverage==7.3.2
elementpath==4.1.5
exceptiongroup==1.1.3
flaky==3.7.0
hypothesis==6.88.3
idna==3.4
iniconfig==1.1.1
mock==4.0.3
iniconfig==2.0.0
mock==5.1.0
mypy==1.6.1
mypy-extensions==1.0.0
nose==1.3.7
packaging==21.3
pluggy==1.0.0
packaging==23.2
pluggy==1.3.0
py==1.11.0
Pygments==2.13.0
pyparsing==3.0.9
Pygments==2.16.1
pytest==7.0.0
requests==2.28.1
requests==2.31.0
sortedcontainers==2.4.0
tomli==2.0.1
trio==0.21.0
urllib3==1.26.12
xmlschema==2.1.1
typing_extensions==4.8.0
urllib3==2.0.7
xmlschema==2.5.0
4 changes: 2 additions & 2 deletions docs/source/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Changelog
=========

0.22.1 (UNRELEASED)
0.23.0 (UNRELEASED)
===================
- Fixes a bug that broke compatibility with pytest>=7.0,<7.2. `#654 <https://github.com/pytest-dev/pytest-asyncio/pull/654>`_
- Removes pytest-trio from the test dependencies `#620 <https://github.com/pytest-dev/pytest-asyncio/pull/620>`_

0.22.0 (2023-10-31)
===================
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ testing =
hypothesis >= 5.7.1
flaky >= 3.5.0
mypy >= 0.931
pytest-trio >= 0.7.0
docs =
sphinx >= 5.3
sphinx-rtd-theme >= 1.0
Expand Down
42 changes: 42 additions & 0 deletions tests/modes/test_strict_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,45 @@ async def test_a(self, fixture_a):
)
result = testdir.runpytest("--asyncio-mode=auto")
result.assert_outcomes(passed=1)


def test_strict_mode_ignores_unmarked_coroutine(testdir):
testdir.makepyfile(
dedent(
"""\
import pytest
async def test_anything():
pass
"""
)
)
result = testdir.runpytest("--asyncio-mode=strict", "-W default")
result.assert_outcomes(skipped=1, warnings=1)
result.stdout.fnmatch_lines(["*async def functions are not natively supported*"])


def test_strict_mode_ignores_unmarked_fixture(testdir):
testdir.makepyfile(
dedent(
"""\
import pytest
# Not using pytest_asyncio.fixture
@pytest.fixture()
async def any_fixture():
raise RuntimeError()
async def test_anything(any_fixture):
pass
"""
)
)
result = testdir.runpytest("--asyncio-mode=strict", "-W default")
result.assert_outcomes(skipped=1, warnings=2)
result.stdout.fnmatch_lines(
[
"*async def functions are not natively supported*",
"*coroutine 'any_fixture' was never awaited*",
],
)
25 changes: 0 additions & 25 deletions tests/trio/test_fixtures.py

This file was deleted.

0 comments on commit 973eaa4

Please sign in to comment.