diff --git a/changelog.d/1334.downstream.rst b/changelog.d/1334.downstream.rst new file mode 100644 index 00000000..ba2e2505 --- /dev/null +++ b/changelog.d/1334.downstream.rst @@ -0,0 +1 @@ +Avoided a ``PytestAssertRewriteWarning`` in the test suite when pytest-asyncio is already imported, such as when tests are run against a system-installed copy on Guix or FreeBSD. diff --git a/tests/markers/test_class_scope.py b/tests/markers/test_class_scope.py index 28f7187c..4ee6951f 100644 --- a/tests/markers/test_class_scope.py +++ b/tests/markers/test_class_scope.py @@ -274,5 +274,5 @@ class TestClass: async def test_anything(self): pass """)) - result = pytester.runpytest("--asyncio-mode=strict") + result = pytester.runpytest("--asyncio-mode=strict", "--assert=plain") result.assert_outcomes(warnings=0, passed=1) diff --git a/tests/markers/test_function_scope.py b/tests/markers/test_function_scope.py index 180d5c71..1e797895 100644 --- a/tests/markers/test_function_scope.py +++ b/tests/markers/test_function_scope.py @@ -72,7 +72,9 @@ def test_warns_when_scope_argument_is_present(pytester: Pytester): async def test_warns(): ... """)) - result = pytester.runpytest("--asyncio-mode=strict", "-W", "default") + result = pytester.runpytest( + "--asyncio-mode=strict", "-W", "default", "--assert=plain" + ) result.assert_outcomes(passed=1, warnings=1) result.stdout.fnmatch_lines("*DeprecationWarning*") diff --git a/tests/markers/test_module_scope.py b/tests/markers/test_module_scope.py index a2662812..c1e6ff99 100644 --- a/tests/markers/test_module_scope.py +++ b/tests/markers/test_module_scope.py @@ -281,5 +281,5 @@ def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_be async def test_anything(): pass """)) - result = pytester.runpytest("--asyncio-mode=strict") + result = pytester.runpytest("--asyncio-mode=strict", "--assert=plain") result.assert_outcomes(warnings=0, passed=1) diff --git a/tests/markers/test_session_scope.py b/tests/markers/test_session_scope.py index 24566c5e..6cd85a55 100644 --- a/tests/markers/test_session_scope.py +++ b/tests/markers/test_session_scope.py @@ -392,5 +392,5 @@ def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_be async def test_anything(): pass """)) - result = pytester.runpytest("--asyncio-mode=strict") + result = pytester.runpytest("--asyncio-mode=strict", "--assert=plain") result.assert_outcomes(warnings=0, passed=1) diff --git a/tests/test_event_loop_fixture.py b/tests/test_event_loop_fixture.py index 8902511b..08355f04 100644 --- a/tests/test_event_loop_fixture.py +++ b/tests/test_event_loop_fixture.py @@ -13,8 +13,6 @@ def test_event_loop_fixture_handles_unclosed_async_gen( import asyncio import pytest - pytest_plugins = 'pytest_asyncio' - @pytest.mark.asyncio async def test_something(): async def generator_fn(): @@ -67,8 +65,6 @@ def test_event_loop_fixture_asyncgen_error( import asyncio import pytest - pytest_plugins = 'pytest_asyncio' - @pytest.mark.asyncio async def test_something(): # mock shutdown_asyncgen failure