Skip to content

Commit cafa26c

Browse files
authored
Drop pytest 6.1 compatibility (#482)
* [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 <m.seifert@digitalernachschub.de> * [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 <m.seifert@digitalernachschub.de> * [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 <m.seifert@digitalernachschub.de> * [refactor] Replace forward reference in event_loop fixture with actual type. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de> * [refactor] Link to Pull Request for exposing FixtureDef and SubRequest in pytest. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de> Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
1 parent 97ece55 commit cafa26c

File tree

7 files changed

+37
-61
lines changed

7 files changed

+37
-61
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Always adjust install_requires in setup.cfg and pytest-min-requirements.txt
22
# when changing runtime dependencies
3-
pytest >= 6.1.0
3+
pytest >= 7.0.0
44
typing-extensions >= 3.7.2; python_version < "3.8"
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
async-generator==1.10
2-
attrs==21.4.0
3-
coverage==6.3.2
4-
flaky==3.7.0
5-
hypothesis==6.43.3
6-
idna==3.3
1+
argcomplete==2.0.0
2+
attrs==22.1.0
3+
certifi==2022.9.24
4+
charset-normalizer==2.1.1
5+
elementpath==3.0.2
6+
exceptiongroup==1.0.0rc9
7+
hypothesis==6.56.3
8+
idna==3.4
79
iniconfig==1.1.1
8-
mypy==0.942
9-
mypy-extensions==0.4.3
10-
outcome==1.1.0
10+
mock==4.0.3
11+
nose==1.3.7
1112
packaging==21.3
12-
pluggy==0.13.1
13+
pluggy==1.0.0
1314
py==1.11.0
14-
pyparsing==3.0.8
15-
pytest==6.1.0
16-
pytest-trio==0.7.0
17-
sniffio==1.2.0
15+
Pygments==2.13.0
16+
pyparsing==3.0.9
17+
pytest==7.0.0
18+
requests==2.28.1
1819
sortedcontainers==2.4.0
19-
toml==0.10.2
2020
tomli==2.0.1
21-
trio==0.20.0
22-
typing_extensions==4.2.0
21+
urllib3==1.26.12
22+
xmlschema==2.1.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Always adjust install_requires in setup.cfg and requirements.txt
22
# when changing minimum version dependencies
3-
pytest == 6.1.0
3+
pytest[testing] == 7.0.0
44
typing-extensions >= 3.7.2; python_version < "3.8"

docs/source/reference/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Changelog
33
=========
44

5+
UNRELEASED
6+
=================
7+
- Drop compatibility with pytest 6.1. Pytest-asyncio now depends on pytest 7.0 or newer.
8+
59
0.20.3 (22-12-08)
610
=================
711
- Prevent DeprecationWarning to bubble up on CPython 3.10.9 and 3.11.1.

pytest_asyncio/plugin.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@
2525
)
2626

2727
import pytest
28-
from pytest import Function, Item, Session
28+
from pytest import (
29+
Config,
30+
FixtureRequest,
31+
Function,
32+
Item,
33+
Parser,
34+
PytestPluginManager,
35+
Session,
36+
)
2937

3038
if sys.version_info >= (3, 8):
3139
from typing import Literal
@@ -46,11 +54,9 @@
4654
FixtureFunction = Union[SimpleFixtureFunction, FactoryFixtureFunction]
4755
FixtureFunctionMarker = Callable[[FixtureFunction], FixtureFunction]
4856

49-
Config = Any # pytest < 7.0
50-
PytestPluginManager = Any # pytest < 7.0
51-
FixtureDef = Any # pytest < 7.0
52-
Parser = Any # pytest < 7.0
53-
SubRequest = Any # pytest < 7.0
57+
# https://github.com/pytest-dev/pytest/pull/9510
58+
FixtureDef = Any
59+
SubRequest = Any
5460

5561

5662
class Mode(str, enum.Enum):
@@ -169,14 +175,6 @@ def pytest_configure(config: Config) -> None:
169175
"run using an asyncio event loop",
170176
)
171177

172-
if getattr(pytest, "version_tuple", (0, 0, 0)) < (7,):
173-
warnings.warn(
174-
"You're using an outdated version of pytest. Newer releases of "
175-
"pytest-asyncio will not be compatible with this pytest version. "
176-
"Please update pytest to version 7 or later.",
177-
DeprecationWarning,
178-
)
179-
180178

181179
@pytest.hookimpl(tryfirst=True)
182180
def pytest_report_header(config: Config) -> List[str]:
@@ -508,7 +506,7 @@ def pytest_runtest_setup(item: pytest.Item) -> None:
508506

509507

510508
@pytest.fixture
511-
def event_loop(request: "pytest.FixtureRequest") -> Iterator[asyncio.AbstractEventLoop]:
509+
def event_loop(request: FixtureRequest) -> Iterator[asyncio.AbstractEventLoop]:
512510
"""Create an instance of the default event loop for each test case."""
513511
loop = asyncio.get_event_loop_policy().new_event_loop()
514512
yield loop

setup.cfg

Lines changed: 1 addition & 1 deletion
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 >= 6.1.0
43+
pytest >= 7.0.0
4444
typing-extensions >= 3.7.2; python_version < "3.8"
4545

4646
[options.extras_require]

tests/test_pytest_min_version_warning.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)