File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -112,3 +112,29 @@ async def test_something(cleanup_after):
112112 )
113113 result = pytester .runpytest_subprocess ("--asyncio-mode=strict" , "-W" , "default" )
114114 result .assert_outcomes (passed = 1 , warnings = 0 )
115+
116+
117+ def test_event_loop_fixture_asyncgen_error (
118+ pytester : Pytester ,
119+ ):
120+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
121+ pytester .makepyfile (
122+ dedent (
123+ """\
124+ import asyncio
125+ import pytest
126+
127+ pytest_plugins = 'pytest_asyncio'
128+
129+ @pytest.mark.asyncio
130+ async def test_something():
131+ # mock shutdown_asyncgen failure
132+ loop = asyncio.get_running_loop()
133+ async def fail():
134+ raise RuntimeError("mock error cleaning up...")
135+ loop.shutdown_asyncgens = fail
136+ """
137+ )
138+ )
139+ result = pytester .runpytest_subprocess ("--asyncio-mode=strict" , "-W" , "default" )
140+ result .assert_outcomes (passed = 1 , warnings = 1 )
You can’t perform that action at this time.
0 commit comments