Skip to content

Commit 6a6b462

Browse files
committed
Work around Python 3.10 exception swallowing
Exceptions raised in __set_name__ are wrapped in a RuntimeError on Python 3.10. The test now allows this if Python < 3.11.
1 parent 1717088 commit 6a6b462

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_properties.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from threading import Thread
23

34
from pytest import raises
@@ -73,16 +74,17 @@ class BasicThing(Thing):
7374

7475
def test_instantiation_with_type_and_model():
7576
"""If a model is specified, we check it matches the inferred type."""
77+
old_python = sys.version_info < (3, 11)
7678

7779
class BasicThing(Thing):
7880
prop = ThingProperty[bool](model=bool, initial_value=False)
7981

80-
with pytest.raises(MismatchedTypeError):
82+
with pytest.raises(RuntimeError if old_python else MismatchedTypeError):
8183

8284
class InvalidThing(Thing):
8385
prop = ThingProperty[bool](model=int, initial_value=False)
8486

85-
with pytest.raises(MissingTypeError):
87+
with pytest.raises(RuntimeError if old_python else MissingTypeError):
8688

8789
class InvalidThing(Thing):
8890
prop = ThingProperty(model=bool, initial_value=False)

0 commit comments

Comments
 (0)