Skip to content

Commit 34ebecb

Browse files
Use monkeypatch to set strict_exception_groups
The pytest tester does not run tests in a subinterpreter or subprocess, so changing trio.run in a testdir test will also change the global trio.run. Monkeypatching resets trio.run after the test.
1 parent ea74f06 commit 34ebecb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pytest_trio/_tests/test_basic.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import functools
12
import pytest
3+
import trio
24

35

46
def test_async_test_is_executed(testdir):
@@ -73,15 +75,17 @@ def test_invalid():
7375
result.assert_outcomes(errors=1)
7476

7577

76-
def test_skip_and_xfail(testdir):
78+
def test_skip_and_xfail(testdir, monkeypatch):
79+
monkeypatch.setattr(
80+
trio, "run", functools.partial(trio.run, strict_exception_groups=True)
81+
)
82+
7783
testdir.makepyfile(
7884
"""
7985
import functools
8086
import pytest
8187
import trio
8288
83-
trio.run = functools.partial(trio.run, strict_exception_groups=True)
84-
8589
@pytest.mark.trio
8690
async def test_xfail():
8791
pytest.xfail()

0 commit comments

Comments
 (0)