Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1334.downstream.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoided a ``PytestAssertRewriteWarning`` in the test suite when it is run from an unpacked sdist. The sdist ships ``pytest_asyncio.egg-info/SOURCES.txt``, which lists ``tests/__init__.py``, so pytest marks the ``tests`` package for assertion rewriting even though it has already been imported by the outer session. This affects downstream distributors such as Guix.
2 changes: 1 addition & 1 deletion tests/markers/test_class_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion tests/markers/test_function_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*")

Expand Down
2 changes: 1 addition & 1 deletion tests/markers/test_module_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/markers/test_session_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 6 additions & 6 deletions tests/test_event_loop_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -24,7 +22,9 @@ async def generator_fn():
gen = generator_fn()
await gen.__anext__()
"""))
result = pytester.runpytest("--asyncio-mode=strict", "-W", "default")
result = pytester.runpytest(
"--asyncio-mode=strict", "-W", "default", "--assert=plain"
)
result.assert_outcomes(passed=1, warnings=0)


Expand Down Expand Up @@ -67,8 +67,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
Expand All @@ -77,5 +75,7 @@ async def fail():
raise RuntimeError("mock error cleaning up...")
loop.shutdown_asyncgens = fail
"""))
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)
Loading