From 4e3cd0f80494993e3bd21848ca1887db37776f8b Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Sun, 15 Jan 2023 12:54:12 +0100 Subject: [PATCH 1/5] [build] Drop compatibility with pytest 6.1. Pytest 7 was released on 2022-02-03, roughly one year ago. It is time to bump the minimum version requirement on pytest. Signed-off-by: Michael Seifert --- dependencies/default/requirements.txt | 2 +- dependencies/pytest-min/constraints.txt | 34 ++++++++++++------------ dependencies/pytest-min/requirements.txt | 2 +- docs/source/reference/changelog.rst | 4 +++ setup.cfg | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/dependencies/default/requirements.txt b/dependencies/default/requirements.txt index 01b2484e..a0009a85 100644 --- a/dependencies/default/requirements.txt +++ b/dependencies/default/requirements.txt @@ -1,4 +1,4 @@ # Always adjust install_requires in setup.cfg and pytest-min-requirements.txt # when changing runtime dependencies -pytest >= 6.1.0 +pytest >= 7.0.0 typing-extensions >= 3.7.2; python_version < "3.8" diff --git a/dependencies/pytest-min/constraints.txt b/dependencies/pytest-min/constraints.txt index 33f7948f..1f82dbaf 100644 --- a/dependencies/pytest-min/constraints.txt +++ b/dependencies/pytest-min/constraints.txt @@ -1,22 +1,22 @@ -async-generator==1.10 -attrs==21.4.0 -coverage==6.3.2 -flaky==3.7.0 -hypothesis==6.43.3 -idna==3.3 +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 +idna==3.4 iniconfig==1.1.1 -mypy==0.942 -mypy-extensions==0.4.3 -outcome==1.1.0 +mock==4.0.3 +nose==1.3.7 packaging==21.3 -pluggy==0.13.1 +pluggy==1.0.0 py==1.11.0 -pyparsing==3.0.8 -pytest==6.1.0 -pytest-trio==0.7.0 -sniffio==1.2.0 +Pygments==2.13.0 +pyparsing==3.0.9 +pytest==7.0.0 +requests==2.28.1 sortedcontainers==2.4.0 -toml==0.10.2 tomli==2.0.1 -trio==0.20.0 -typing_extensions==4.2.0 +urllib3==1.26.12 +xmlschema==2.1.1 diff --git a/dependencies/pytest-min/requirements.txt b/dependencies/pytest-min/requirements.txt index 4fc6ef2f..4152d2f8 100644 --- a/dependencies/pytest-min/requirements.txt +++ b/dependencies/pytest-min/requirements.txt @@ -1,4 +1,4 @@ # Always adjust install_requires in setup.cfg and requirements.txt # when changing minimum version dependencies -pytest == 6.1.0 +pytest[testing] == 7.0.0 typing-extensions >= 3.7.2; python_version < "3.8" diff --git a/docs/source/reference/changelog.rst b/docs/source/reference/changelog.rst index e6f80383..af4eb7bf 100644 --- a/docs/source/reference/changelog.rst +++ b/docs/source/reference/changelog.rst @@ -2,6 +2,10 @@ Changelog ========= +UNRELEASED +================= +- Drop compatibility with pytest 6.1. Pytest-asyncio now depends on pytest 7.0 or newer. + 0.20.3 (22-12-08) ================= - Prevent DeprecationWarning to bubble up on CPython 3.10.9 and 3.11.1. diff --git a/setup.cfg b/setup.cfg index a82c57e1..ee57438c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,7 +40,7 @@ include_package_data = True # Always adjust requirements.txt and pytest-min-requirements.txt when changing runtime dependencies install_requires = - pytest >= 6.1.0 + pytest >= 7.0.0 typing-extensions >= 3.7.2; python_version < "3.8" [options.extras_require] From bf7604662f1e8ebbdd7a3a81baa1bea65bd166d6 Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Sun, 15 Jan 2023 13:09:23 +0100 Subject: [PATCH 2/5] [refactor] Replace custom type aliases for with pytest types. The types Config, PytestPluginManager, and Parser are available as part of the public pytest API starting from pytest 7. Signed-off-by: Michael Seifert --- pytest_asyncio/plugin.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 403d814f..1da79741 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -25,7 +25,7 @@ ) import pytest -from pytest import Function, Item, Session +from pytest import Config, Function, Item, Parser, PytestPluginManager, Session if sys.version_info >= (3, 8): from typing import Literal @@ -46,10 +46,7 @@ FixtureFunction = Union[SimpleFixtureFunction, FactoryFixtureFunction] FixtureFunctionMarker = Callable[[FixtureFunction], FixtureFunction] -Config = Any # pytest < 7.0 -PytestPluginManager = Any # pytest < 7.0 FixtureDef = Any # pytest < 7.0 -Parser = Any # pytest < 7.0 SubRequest = Any # pytest < 7.0 From e6e73a59845bedf8c03203bf1ab3db1ec277dbdf Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Sun, 15 Jan 2023 14:46:43 +0100 Subject: [PATCH 3/5] [refactor] Remove deprecation warning when using a pytest version lower than 7. The minimum pytest version was bumped to v7, so this deprecation warning should never be triggered. Signed-off-by: Michael Seifert --- pytest_asyncio/plugin.py | 8 -------- tests/test_pytest_min_version_warning.py | 26 ------------------------ 2 files changed, 34 deletions(-) delete mode 100644 tests/test_pytest_min_version_warning.py diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 1da79741..23846cfd 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -166,14 +166,6 @@ def pytest_configure(config: Config) -> None: "run using an asyncio event loop", ) - if getattr(pytest, "version_tuple", (0, 0, 0)) < (7,): - warnings.warn( - "You're using an outdated version of pytest. Newer releases of " - "pytest-asyncio will not be compatible with this pytest version. " - "Please update pytest to version 7 or later.", - DeprecationWarning, - ) - @pytest.hookimpl(tryfirst=True) def pytest_report_header(config: Config) -> List[str]: diff --git a/tests/test_pytest_min_version_warning.py b/tests/test_pytest_min_version_warning.py deleted file mode 100644 index 5f7bd72f..00000000 --- a/tests/test_pytest_min_version_warning.py +++ /dev/null @@ -1,26 +0,0 @@ -from textwrap import dedent - -import pytest - - -@pytest.mark.skipif( - pytest.__version__ < "7.0.0", - reason="The warning shouldn't be present when run with recent pytest versions", -) -@pytest.mark.parametrize("mode", ("auto", "strict")) -def test_pytest_min_version_warning_is_not_triggered_for_pytest_7(testdir, mode): - testdir.makepyfile( - dedent( - """\ - import pytest - - pytest_plugins = 'pytest_asyncio' - - @pytest.mark.asyncio - async def test_triggers_pytest_warning(): - pass - """ - ) - ) - result = testdir.runpytest(f"--asyncio-mode={mode}") - result.assert_outcomes(passed=1, warnings=0) From 31e8e6a939baff11f6098b2787f1dad01e8bbdec Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Sun, 15 Jan 2023 14:53:58 +0100 Subject: [PATCH 4/5] [refactor] Replace forward reference in event_loop fixture with actual type. Signed-off-by: Michael Seifert --- pytest_asyncio/plugin.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 23846cfd..84b088f7 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -25,7 +25,15 @@ ) import pytest -from pytest import Config, Function, Item, Parser, PytestPluginManager, Session +from pytest import ( + Config, + FixtureRequest, + Function, + Item, + Parser, + PytestPluginManager, + Session, +) if sys.version_info >= (3, 8): from typing import Literal @@ -497,7 +505,7 @@ def pytest_runtest_setup(item: pytest.Item) -> None: @pytest.fixture -def event_loop(request: "pytest.FixtureRequest") -> Iterator[asyncio.AbstractEventLoop]: +def event_loop(request: FixtureRequest) -> Iterator[asyncio.AbstractEventLoop]: """Create an instance of the default event loop for each test case.""" loop = asyncio.get_event_loop_policy().new_event_loop() yield loop From 83519012a8f014844f4b69baf567391f0551c5bb Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Sun, 15 Jan 2023 14:57:36 +0100 Subject: [PATCH 5/5] [refactor] Link to Pull Request for exposing FixtureDef and SubRequest in pytest. Signed-off-by: Michael Seifert --- pytest_asyncio/plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 84b088f7..f663ff68 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -54,8 +54,9 @@ FixtureFunction = Union[SimpleFixtureFunction, FactoryFixtureFunction] FixtureFunctionMarker = Callable[[FixtureFunction], FixtureFunction] -FixtureDef = Any # pytest < 7.0 -SubRequest = Any # pytest < 7.0 +# https://github.com/pytest-dev/pytest/pull/9510 +FixtureDef = Any +SubRequest = Any class Mode(str, enum.Enum):