Skip to content

Commit 42b140d

Browse files
akeemanseifertm
andauthored
fix compatibility with pytest ^8 (#776)
* fix compatibility with pytest ^8 * [build] Limit maximum pytest version to v9 and remove pytest-8.0.0rc1 and pytest-8.0.0rc2 from the excluded versions. Signed-off-by: Michael Seifert <[email protected]> * [build] Revert minimum pytest version to v7. This should allow users to update pytest independently from pytest-asyncio. Signed-off-by: Michael Seifert <[email protected]> * [docs] Add changelog entry for pytest 8 compatibility. Signed-off-by: Michael Seifert <[email protected]> --------- Signed-off-by: Michael Seifert <[email protected]> Co-authored-by: Michael Seifert <[email protected]>
1 parent e92efad commit 42b140d

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

dependencies/default/constraints.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ hypothesis==6.96.2
55
iniconfig==2.0.0
66
packaging==23.2
77
pluggy==1.3.0
8-
pytest==7.4.4
8+
pytest==8.0.0
99
sortedcontainers==2.4.0
1010
tomli==2.0.1
1111
typing_extensions==4.9.0

dependencies/default/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Always adjust install_requires in setup.cfg and pytest-min-requirements.txt
22
# when changing runtime dependencies
3-
pytest >= 7.0.0,<8
3+
pytest >= 7.0.0,<9

docs/source/reference/changelog.rst

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
Changelog
33
=========
44

5+
0.23.5 (UNRELEASED)
6+
===================
7+
- Declare compatibility with pytest 8 `#737 <https://github.com/pytest-dev/pytest-asyncio/issues/737>`_
8+
9+
Known issues
10+
------------
11+
As of v0.23, pytest-asyncio attaches an asyncio event loop to each item of the test suite (i.e. session, packages, modules, classes, functions) and allows tests to be run in those loops when marked accordingly. Pytest-asyncio currently assumes that async fixture scope is correlated with the new event loop scope. This prevents fixtures from being evaluated independently from the event loop scope and breaks some existing test suites (see `#706`_). For example, a test suite may require all fixtures and tests to run in the same event loop, but have async fixtures that are set up and torn down for each module. If you're affected by this issue, please continue using the v0.21 release, until it is resolved.
12+
13+
514
0.23.4 (2024-01-28)
615
===================
716
- pytest-asyncio no longer imports additional, unrelated packages during test collection `#729 <https://github.com/pytest-dev/pytest-asyncio/issues/729>`_

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ include_package_data = True
4040

4141
# Always adjust requirements.txt and pytest-min-requirements.txt when changing runtime dependencies
4242
install_requires =
43-
pytest >= 7.0.0,<8
43+
pytest >= 7.0.0,<9
4444

4545
[options.extras_require]
4646
testing =

tests/markers/test_session_scope.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ async def test_this_runs_in_same_loop(self):
4444
"""
4545
),
4646
)
47-
subpackage_name = "subpkg"
47+
48+
# subpackage_name must alphabetically come after test_module_one.py
49+
subpackage_name = "z_subpkg"
4850
subpkg = pytester.mkpydir(subpackage_name)
4951
subpkg.joinpath("test_subpkg.py").write_text(
5052
dedent(

tests/test_is_async_test.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ def pytest_collection_modifyitems(items):
7777
if pytest.version_tuple < (7, 2):
7878
# Probably related to https://github.com/pytest-dev/pytest/pull/10012
7979
result.assert_outcomes(failed=1)
80-
else:
80+
elif pytest.version_tuple < (8,):
8181
result.assert_outcomes(skipped=1)
82+
else:
83+
result.assert_outcomes(failed=1)
8284

8385

8486
def test_returns_true_for_unmarked_coroutine_item_in_auto_mode(pytester: Pytester):

0 commit comments

Comments
 (0)