@@ -10,10 +10,11 @@ def test_timeout_ok(pytester):
10
10
import asyncio
11
11
import pytest
12
12
13
- pytest_plugins = 'pytest_asyncio'
13
+ pytest_plugins = [ 'pytest_asyncio']
14
14
15
- @pytest.mark.asyncio(timeout=0.01)
16
15
@pytest.mark.xfail(strict=True, raises=asyncio.TimeoutError)
16
+ @pytest.mark.timeout(0.01)
17
+ @pytest.mark.asyncio
17
18
async def test_a():
18
19
await asyncio.sleep(1)
19
20
"""
@@ -30,9 +31,10 @@ def test_timeout_disabled(pytester):
30
31
import asyncio
31
32
import pytest
32
33
33
- pytest_plugins = 'pytest_asyncio'
34
+ pytest_plugins = [ 'pytest_asyncio']
34
35
35
- @pytest.mark.asyncio(timeout=0)
36
+ @pytest.mark.timeout(0)
37
+ @pytest.mark.asyncio
36
38
async def test_a():
37
39
await asyncio.sleep(0.01)
38
40
"""
@@ -42,34 +44,14 @@ async def test_a():
42
44
result .assert_outcomes (passed = 1 )
43
45
44
46
45
- def test_timeout_not_numeric (pytester ):
46
- pytester .makepyfile (
47
- dedent (
48
- """\
49
- import asyncio
50
- import pytest
51
-
52
- pytest_plugins = 'pytest_asyncio'
53
-
54
- @pytest.mark.asyncio(timeout="abc")
55
- @pytest.mark.xfail(strict=True, raises=ValueError)
56
- async def test_a():
57
- await asyncio.sleep(0.01)
58
- """
59
- )
60
- )
61
- result = pytester .runpytest ("--asyncio-mode=strict" )
62
- result .assert_outcomes (xfailed = 1 )
63
-
64
-
65
47
def test_timeout_cmdline (pytester ):
66
48
pytester .makepyfile (
67
49
dedent (
68
50
"""\
69
51
import asyncio
70
52
import pytest
71
53
72
- pytest_plugins = 'pytest_asyncio'
54
+ pytest_plugins = [ 'pytest_asyncio']
73
55
74
56
@pytest.mark.asyncio
75
57
@pytest.mark.xfail(strict=True, raises=asyncio.TimeoutError)
@@ -78,26 +60,5 @@ async def test_a():
78
60
"""
79
61
)
80
62
)
81
- result = pytester .runpytest ("--asyncio-timeout=0.01" , "--asyncio-mode=strict" )
82
- result .assert_outcomes (xfailed = 1 )
83
-
84
-
85
- def test_timeout_cfg (pytester ):
86
- pytester .makepyfile (
87
- dedent (
88
- """\
89
- import asyncio
90
- import pytest
91
-
92
- pytest_plugins = 'pytest_asyncio'
93
-
94
- @pytest.mark.asyncio
95
- @pytest.mark.xfail(strict=True, raises=asyncio.TimeoutError)
96
- async def test_a():
97
- await asyncio.sleep(1)
98
- """
99
- )
100
- )
101
- pytester .makefile (".ini" , pytest = "[pytest]\n asyncio_timeout = 0.01\n " )
102
- result = pytester .runpytest ("--asyncio-mode=strict" )
63
+ result = pytester .runpytest ("--timeout=0.01" , "--asyncio-mode=strict" )
103
64
result .assert_outcomes (xfailed = 1 )
0 commit comments