Skip to content

Commit 46ff8e6

Browse files
committed
Test the stub BaseProperty.__set__
I added a __set__ to BaseProperty to satisfy mypy, so now there is a test to check it raises an error and is overridden.
1 parent 6e8e279 commit 46ff8e6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_property.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@ class Example:
220220
assert set(entry.keys()) == set(["get", "put"])
221221

222222

223+
def test_baseproperty_set_error():
224+
"""Check `.Baseproperty.__set__` raises an error and is overridden."""
225+
assert tp.DataProperty.__get__ is tp.BaseProperty.__get__
226+
assert tp.DataProperty.__set__ is not tp.BaseProperty.__set__
227+
assert tp.FunctionalProperty.__set__ is not tp.BaseProperty.__set__
228+
229+
class Example:
230+
bp: int = tp.BaseProperty()
231+
232+
example = Example()
233+
with pytest.raises(NotImplementedError):
234+
example.bp = 0
235+
236+
223237
def test_decorator_exception():
224238
r"""Check decorators work as expected when the setter has a different name.
225239

0 commit comments

Comments
 (0)