Skip to content

Commit

Permalink
fix compatibility with pytest ^8 (#776)
Browse files Browse the repository at this point in the history
* 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 <m.seifert@digitalernachschub.de>

* [build] Revert minimum pytest version to v7.

This should allow users to update pytest independently from pytest-asyncio.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>

* [docs] Add changelog entry for pytest 8 compatibility.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>

---------

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
Co-authored-by: Michael Seifert <m.seifert@digitalernachschub.de>
  • Loading branch information
akeeman and seifertm committed Feb 6, 2024
1 parent e92efad commit 42b140d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dependencies/default/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hypothesis==6.96.2
iniconfig==2.0.0
packaging==23.2
pluggy==1.3.0
pytest==7.4.4
pytest==8.0.0
sortedcontainers==2.4.0
tomli==2.0.1
typing_extensions==4.9.0
2 changes: 1 addition & 1 deletion dependencies/default/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Always adjust install_requires in setup.cfg and pytest-min-requirements.txt
# when changing runtime dependencies
pytest >= 7.0.0,<8
pytest >= 7.0.0,<9
9 changes: 9 additions & 0 deletions docs/source/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog
=========

0.23.5 (UNRELEASED)
===================
- Declare compatibility with pytest 8 `#737 <https://github.com/pytest-dev/pytest-asyncio/issues/737>`_

Known issues
------------
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.


0.23.4 (2024-01-28)
===================
- pytest-asyncio no longer imports additional, unrelated packages during test collection `#729 <https://github.com/pytest-dev/pytest-asyncio/issues/729>`_
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ include_package_data = True

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

[options.extras_require]
testing =
Expand Down
4 changes: 3 additions & 1 deletion tests/markers/test_session_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ async def test_this_runs_in_same_loop(self):
"""
),
)
subpackage_name = "subpkg"

# subpackage_name must alphabetically come after test_module_one.py
subpackage_name = "z_subpkg"
subpkg = pytester.mkpydir(subpackage_name)
subpkg.joinpath("test_subpkg.py").write_text(
dedent(
Expand Down
4 changes: 3 additions & 1 deletion tests/test_is_async_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ def pytest_collection_modifyitems(items):
if pytest.version_tuple < (7, 2):
# Probably related to https://github.com/pytest-dev/pytest/pull/10012
result.assert_outcomes(failed=1)
else:
elif pytest.version_tuple < (8,):
result.assert_outcomes(skipped=1)
else:
result.assert_outcomes(failed=1)


def test_returns_true_for_unmarked_coroutine_item_in_auto_mode(pytester: Pytester):
Expand Down

0 comments on commit 42b140d

Please sign in to comment.