File tree 2 files changed +64
-12
lines changed
2 files changed +64
-12
lines changed Original file line number Diff line number Diff line change @@ -240,15 +240,3 @@ async def test_no_warning_on_skip():
240
240
def test_async_close_loop (event_loop ):
241
241
event_loop .close ()
242
242
return "ok"
243
-
244
-
245
- @pytest .mark .asyncio (timeout = 0.1 )
246
- @pytest .mark .xfail (strict = True , raises = asyncio .TimeoutError )
247
- async def test_timeout ():
248
- await asyncio .sleep (1 )
249
-
250
-
251
- @pytest .mark .asyncio (timeout = "abc" )
252
- @pytest .mark .xfail (strict = True , raises = ValueError )
253
- async def test_timeout_not_numeric ():
254
- await asyncio .sleep (1 )
Original file line number Diff line number Diff line change
1
+ import asyncio
2
+ from textwrap import dedent
3
+
4
+ import pytest
5
+
6
+ pytest_plugins = "pytester"
7
+
8
+
9
+ @pytest .mark .asyncio (timeout = 0.01 )
10
+ @pytest .mark .xfail (strict = True , raises = asyncio .TimeoutError )
11
+ async def test_timeout ():
12
+ await asyncio .sleep (1 )
13
+
14
+
15
+ @pytest .mark .asyncio (timeout = 0 )
16
+ async def test_timeout_disabled ():
17
+ await asyncio .sleep (0.01 )
18
+
19
+
20
+ @pytest .mark .asyncio (timeout = "abc" )
21
+ @pytest .mark .xfail (strict = True , raises = ValueError )
22
+ async def test_timeout_not_numeric ():
23
+ await asyncio .sleep (1 )
24
+
25
+
26
+ def test_timeout_cmdline (pytester ):
27
+ pytester .makepyfile (
28
+ dedent (
29
+ """\
30
+ import asyncio
31
+ import pytest
32
+
33
+ pytest_plugins = 'pytest_asyncio'
34
+
35
+ @pytest.mark.asyncio
36
+ @pytest.mark.xfail(strict=True, raises=asyncio.TimeoutError)
37
+ async def test_a():
38
+ await asyncio.sleep(1)
39
+ """
40
+ )
41
+ )
42
+ result = pytester .runpytest ("--asyncio-timeout=0.01" , "--asyncio-mode=strict" )
43
+ result .assert_outcomes (xfailed = 1 )
44
+
45
+
46
+ def test_timeout_cfg (pytester ):
47
+ pytester .makepyfile (
48
+ dedent (
49
+ """\
50
+ import asyncio
51
+ import pytest
52
+
53
+ pytest_plugins = 'pytest_asyncio'
54
+
55
+ @pytest.mark.asyncio
56
+ @pytest.mark.xfail(strict=True, raises=asyncio.TimeoutError)
57
+ async def test_a():
58
+ await asyncio.sleep(1)
59
+ """
60
+ )
61
+ )
62
+ pytester .makefile (".ini" , pytest = "[pytest]\n asyncio_timeout = 0.01\n " )
63
+ result = pytester .runpytest ("--asyncio-mode=strict" )
64
+ result .assert_outcomes (xfailed = 1 )
You can’t perform that action at this time.
0 commit comments