Skip to content

Commit

Permalink
Adds a test for property setter
Browse files Browse the repository at this point in the history
  • Loading branch information
hippo91 authored and Pierre-Sassoulas committed Feb 10, 2021
1 parent 61a0347 commit 7179392
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/unittest_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5494,14 +5494,19 @@ class A:
def test(self):
return 42
@test.setter
def test(self, value):
return "banco"
A.test #@
A().test #@
A.test.fget(A) #@
A.test.fset(A, "a_value") #@
A.test.setter #@
A.test.getter #@
A.test.deleter #@
"""
prop, prop_result, prop_fget_result, prop_setter, prop_getter, prop_deleter = extract_node(
prop, prop_result, prop_fget_result, prop_fset_result, prop_setter, prop_getter, prop_deleter = extract_node(
code
)

Expand All @@ -5519,6 +5524,10 @@ def test(self):
assert isinstance(inferred, nodes.Const)
assert inferred.value == 42

inferred = next(prop_fset_result.infer())
assert isinstance(inferred, nodes.Const)
assert inferred.value == "banco"

for prop_func in prop_setter, prop_getter, prop_deleter:
inferred = next(prop_func.infer())
assert isinstance(inferred, nodes.FunctionDef)
Expand Down

0 comments on commit 7179392

Please sign in to comment.