Skip to content

Commit

Permalink
fix: Do not warn about outdated pytest version when pytest>=7 is inst…
Browse files Browse the repository at this point in the history
…alled. (#431)

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
  • Loading branch information
seifertm committed Oct 21, 2022
1 parent 6450ddb commit c8d0174
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog
=========

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 <https://github.com/pytest-dev/pytest-asyncio/issues/430>`_

0.20.0 (22-10-21)
=================
- 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.
Expand Down
2 changes: 1 addition & 1 deletion pytest_asyncio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def pytest_configure(config: Config) -> None:
"run using an asyncio event loop",
)

if getattr(pytest, "__version_tuple__", (0, 0, 0) < (7,)):
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. "
Expand Down
26 changes: 26 additions & 0 deletions tests/test_pytest_min_version_warning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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)

0 comments on commit c8d0174

Please sign in to comment.