-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtest_timeout.py
50 lines (37 loc) · 1.14 KB
/
test_timeout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import trio
import functools
def test_timeout(testdir):
testdir.makepyfile(
"""
from trio import sleep
import pytest
import pytest_trio.timeout
@pytest.mark.timeout(0.01)
@pytest.mark.trio
async def test_will_timeout():
await sleep(10)
"""
)
testdir.makefile(".ini", pytest="[pytest]\ntrio_timeout=true\n")
result = testdir.runpytest()
result.stdout.fnmatch_lines(["Timeout reached"])
result.assert_outcomes(failed=1)
def test_timeout_strict_exception_group(testdir, monkeypatch):
monkeypatch.setattr(
trio, "run", functools.partial(trio.run, strict_exception_groups=True)
)
testdir.makepyfile(
"""
from trio import sleep
import pytest
import pytest_trio.timeout
@pytest.mark.timeout(0.01)
@pytest.mark.trio
async def test_will_timeout():
await sleep(10)
"""
)
testdir.makefile(".ini", pytest="[pytest]\ntrio_timeout=true\n")
result = testdir.runpytest()
result.stdout.fnmatch_lines(["Timeout reached"])
result.assert_outcomes(failed=1)