-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7404b79
commit 797a19a
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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) |