File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import trio
2
+ import functools
3
+
4
+
5
+ def test_timeout (testdir ):
6
+ testdir .makepyfile (
7
+ """
8
+ from trio import sleep
9
+ import pytest
10
+ import pytest_trio.timeout
11
+
12
+ @pytest.mark.timeout(0.01)
13
+ @pytest.mark.trio
14
+ async def test_will_timeout():
15
+ await sleep(10)
16
+ """
17
+ )
18
+
19
+ testdir .makefile (".ini" , pytest = "[pytest]\n trio_timeout=true\n " )
20
+
21
+ result = testdir .runpytest ()
22
+
23
+ result .stdout .fnmatch_lines (["Timeout reached" ])
24
+ result .assert_outcomes (failed = 1 )
25
+
26
+
27
+ def test_timeout_strict_exception_group (testdir , monkeypatch ):
28
+ monkeypatch .setattr (
29
+ trio , "run" , functools .partial (trio .run , strict_exception_groups = True )
30
+ )
31
+
32
+ testdir .makepyfile (
33
+ """
34
+ from trio import sleep
35
+ import pytest
36
+ import pytest_trio.timeout
37
+
38
+ @pytest.mark.timeout(0.01)
39
+ @pytest.mark.trio
40
+ async def test_will_timeout():
41
+ await sleep(10)
42
+ """
43
+ )
44
+
45
+ testdir .makefile (".ini" , pytest = "[pytest]\n trio_timeout=true\n " )
46
+
47
+ result = testdir .runpytest ()
48
+
49
+ result .stdout .fnmatch_lines (["Timeout reached" ])
50
+ result .assert_outcomes (failed = 1 )
You can’t perform that action at this time.
0 commit comments