Skip to content

Commit c8d0174

Browse files
authored
fix: Do not warn about outdated pytest version when pytest>=7 is installed. (pytest-dev#431)
Signed-off-by: Michael Seifert <[email protected]>
1 parent 6450ddb commit c8d0174

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

CHANGELOG.rst

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

5+
0.20.1 (22-10-21)
6+
=================
7+
- Fixes an issue that warned about using an old version of pytest, even though the most recent version was installed. `#430 <https://github.com/pytest-dev/pytest-asyncio/issues/430>`_
8+
59
0.20.0 (22-10-21)
610
=================
711
- BREAKING: Removed *legacy* mode. If you're upgrading from v0.19 and you haven't configured ``asyncio_mode = legacy``, you can upgrade without taking any additional action. If you're upgrading from an earlier version or you have explicitly enabled *legacy* mode, you need to switch to *auto* or *strict* mode before upgrading to this version.

pytest_asyncio/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def pytest_configure(config: Config) -> None:
171171
"run using an asyncio event loop",
172172
)
173173

174-
if getattr(pytest, "__version_tuple__", (0, 0, 0) < (7,)):
174+
if getattr(pytest, "version_tuple", (0, 0, 0)) < (7,):
175175
warnings.warn(
176176
"You're using an outdated version of pytest. Newer releases of "
177177
"pytest-asyncio will not be compatible with this pytest version. "
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from textwrap import dedent
2+
3+
import pytest
4+
5+
6+
@pytest.mark.skipif(
7+
pytest.__version__ < "7.0.0",
8+
reason="The warning shouldn't be present when run with recent pytest versions"
9+
)
10+
@pytest.mark.parametrize("mode", ("auto", "strict"))
11+
def test_pytest_min_version_warning_is_not_triggered_for_pytest_7(testdir, mode):
12+
testdir.makepyfile(
13+
dedent(
14+
"""\
15+
import pytest
16+
17+
pytest_plugins = 'pytest_asyncio'
18+
19+
@pytest.mark.asyncio
20+
async def test_triggers_pytest_warning():
21+
pass
22+
"""
23+
)
24+
)
25+
result = testdir.runpytest(f"--asyncio-mode={mode}")
26+
result.assert_outcomes(passed=1, warnings=0)

0 commit comments

Comments
 (0)