Skip to content

Commit 34016fe

Browse files
committed
fix: Do not warn about outdated pytest version when pytest>=7 is installed.
Signed-off-by: Michael Seifert <[email protected]>
1 parent 6450ddb commit 34016fe

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

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+
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

Lines changed: 1 addition & 1 deletion
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. "
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 should be present when run in the pytest-min environment"
9+
)
10+
@pytest.mark.parametrize("mode", ("auto", "strict"))
11+
def test_pytest_min_version_warning_is_triggered_for_pytest_6(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+
findings = result.parseoutcomes()
27+
assert findings["passed"] == 1
28+
assert findings["warnings"] > 0
29+
30+
31+
@pytest.mark.skipif(
32+
pytest.__version__ < "7.0.0",
33+
reason="The warning shouldn't be present when run with recent pytest versions"
34+
)
35+
@pytest.mark.parametrize("mode", ("auto", "strict"))
36+
def test_pytest_min_version_warning_is_not_triggered_for_pytest_7(testdir, mode):
37+
testdir.makepyfile(
38+
dedent(
39+
"""\
40+
import pytest
41+
42+
pytest_plugins = 'pytest_asyncio'
43+
44+
@pytest.mark.asyncio
45+
async def test_triggers_pytest_warning():
46+
pass
47+
"""
48+
)
49+
)
50+
result = testdir.runpytest(f"--asyncio-mode={mode}")
51+
result.assert_outcomes(passed=1, warnings=0)

0 commit comments

Comments
 (0)