We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 338753b commit 8bb51f4Copy full SHA for 8bb51f4
tests/test_event_loop_cleanup.py
@@ -0,0 +1,38 @@
1
+from textwrap import dedent
2
+
3
4
+def test_task_canceled_on_test_end(testdir):
5
+ testdir.makepyfile(
6
+ dedent(
7
+ """\
8
+ import asyncio
9
+ import pytest
10
11
+ pytest_plugins = 'pytest_asyncio'
12
13
+ @pytest.mark.asyncio
14
+ async def test_a():
15
+ loop = asyncio.get_event_loop()
16
17
+ async def run_forever():
18
+ while True:
19
+ await asyncio.sleep(0.1)
20
21
+ loop.create_task(run_forever())
22
+ """
23
+ )
24
25
+ testdir.makefile(
26
+ ".ini",
27
+ pytest=dedent(
28
29
+ [pytest]
30
+ asyncio_mode = strict
31
+ filterwarnings =
32
+ error
33
34
+ ),
35
36
+ result = testdir.runpytest_subprocess()
37
+ result.assert_outcomes(passed=1)
38
+ result.stderr.no_fnmatch_line("Task was destroyed but it is pending!")
0 commit comments