From ed17190e6a08fff5482507d120dfcb0f970d3c72 Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Tue, 1 Nov 2022 09:41:53 +0100 Subject: [PATCH 1/3] refactor: Address deprecation of @pytest.mark.tryfirst. Signed-off-by: Michael Seifert --- CHANGELOG.rst | 4 ++++ pytest_asyncio/plugin.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5c84b46e..34fe9c08 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,10 @@ Changelog ========= +UNRELEASED +================= +- Replaced usage of deprecated ``@pytest.mark.tryfirst`` with ``@pytest.hookimpl(tryfirst=True)`` `#438 `_ + 0.20.1 (22-10-21) ================= - Fixes an issue that warned about using an old version of pytest, even though the most recent version was installed. `#430 `_ diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 3b7b2304..17268c9b 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -180,7 +180,7 @@ def pytest_configure(config: Config) -> None: ) -@pytest.mark.tryfirst +@pytest.hookimpl(tryfirst=True) def pytest_report_header(config: Config) -> List[str]: """Add asyncio config to pytest header.""" mode = _get_asyncio_mode(config) @@ -299,7 +299,7 @@ async def setup() -> _R: _HOLDER: Set[FixtureDef] = set() -@pytest.mark.tryfirst +@pytest.hookimpl(tryfirst=True) def pytest_pycollect_makeitem( collector: Union[pytest.Module, pytest.Class], name: str, obj: object ) -> Union[ From a8b947a056edcea61656c8b1f0a029513d9a07ed Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Tue, 1 Nov 2022 09:42:33 +0100 Subject: [PATCH 2/3] test: Remove return value from test case. Return values in tests are deprecated starting from pytest 7.2 and will result in a warning. Signed-off-by: Michael Seifert --- tests/test_simple.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_simple.py b/tests/test_simple.py index dc68d61e..7b87a7f4 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -240,7 +240,6 @@ async def test_no_warning_on_skip(): def test_async_close_loop(event_loop): event_loop.close() - return "ok" def test_warn_asyncio_marker_for_regular_func(testdir): From 2b696faab7ad3d43eb630a1c44e57009b1ec318a Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Tue, 1 Nov 2022 09:42:54 +0100 Subject: [PATCH 3/3] build: Bump pytest to v7.2.0. Signed-off-by: Michael Seifert --- dependencies/default/constraints.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dependencies/default/constraints.txt b/dependencies/default/constraints.txt index d8925ba9..b8cc7fc6 100644 --- a/dependencies/default/constraints.txt +++ b/dependencies/default/constraints.txt @@ -1,6 +1,7 @@ async-generator==1.10 attrs==22.1.0 coverage==6.5.0 +exceptiongroup==1.0.0 flaky==3.7.0 hypothesis==6.56.4 idna==3.4 @@ -11,9 +12,8 @@ mypy-extensions==0.4.3 outcome==1.2.0 packaging==21.3 pluggy==1.0.0 -py==1.11.0 pyparsing==3.0.9 -pytest==7.1.3 +pytest==7.2.0 pytest-trio==0.7.0 sniffio==1.3.0 sortedcontainers==2.4.0