1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
From: Colin Watson <cjwatson@debian.org>
Date: Wed, 10 Sep 2025 01:00:47 +0100
Subject: tests: Ignore warning when running with installed pytest_asyncio
This happens in autopkgtests.
Forwarded: not-needed
Last-Update: 2025-10-10
---
tests/test_event_loop_fixture.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
--- a/tests/test_event_loop_fixture.py
+++ b/tests/test_event_loop_fixture.py
@@ -5,6 +5,13 @@
from pytest import Pytester
+_ignore_installed_warning = (
+ "ignore"
+ ":Module already imported so cannot be rewritten; pytest_asyncio"
+ ":pytest.PytestAssertRewriteWarning"
+)
+
+
def test_event_loop_fixture_handles_unclosed_async_gen(
pytester: Pytester,
):
@@ -28,7 +35,9 @@
"""
)
)
- result = pytester.runpytest("--asyncio-mode=strict", "-W", "default")
+ result = pytester.runpytest(
+ "--asyncio-mode=strict", "-W", "default", "-W", _ignore_installed_warning
+ )
result.assert_outcomes(passed=1, warnings=0)
@@ -89,5 +98,7 @@
"""
)
)
- result = pytester.runpytest("--asyncio-mode=strict", "-W", "default")
+ result = pytester.runpytest(
+ "--asyncio-mode=strict", "-W", "default", "-W", _ignore_installed_warning
+ )
result.assert_outcomes(passed=1, warnings=1)
|