Skip to content

Commit 8c147fa

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 527fd44 commit 8c147fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pytest_trio/_tests/test_basic.py

Lines changed: 5 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,15 @@ 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(trio, "run", functools.partial(trio.run, strict_exception_groups=True))
80+
7781
testdir.makepyfile(
7882
"""
7983
import functools
8084
import pytest
8185
import trio
8286
83-
trio.run = functools.partial(trio.run, strict_exception_groups=True)
84-
8587
@pytest.mark.trio
8688
async def test_xfail():
8789
pytest.xfail()

0 commit comments

Comments
 (0)