Skip to content

Commit 59e001b

Browse files
committed
Improve raises() helper
1 parent b73d6fd commit 59e001b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hypothesis-python/tests/common/utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import contextlib
1212
import sys
1313
from io import StringIO
14+
from types import SimpleNamespace
1415

1516
from hypothesis import Phase, settings
1617
from hypothesis.errors import HypothesisDeprecationWarning
@@ -29,9 +30,11 @@
2930

3031
@contextlib.contextmanager
3132
def raises(expected_exception, match=None):
33+
err = SimpleNamespace(value=None)
3234
try:
33-
yield
35+
yield err
3436
except expected_exception as e:
37+
err.value = e
3538
if match is not None:
3639
import re
3740

0 commit comments

Comments
 (0)