Skip to content

Commit ab54ce7

Browse files
committed
Add a comment, and test both object and class attributes
Thanks @bprobert97 for spotting that. I added an explicit check that the descriptor is returned when accessed as a class attribute to this test. It was already being implicitly tested in some of the other tests, but this feels clear and helpful.
1 parent 531e87e commit ab54ce7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_base_descriptor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,13 @@ def test_basedescriptor_fallback():
7272

7373

7474
def test_basedescriptor_get():
75+
"""Check the __get__ function works
76+
77+
BaseDescriptor provides an implementation of __get__ that
78+
returns the descriptor when accessed as a class attribute,
79+
and calls `instance_get` when accessed as the attribute of
80+
an instance. This test checks both those scenarios.
81+
"""
7582
e = Example()
7683
assert e.my_property == "An example value."
84+
assert isinstance(Example.my_property, MockProperty)

0 commit comments

Comments
 (0)