summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhippo91 <guillaume.peillex@gmail.com>2021-02-07 16:13:43 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-02-10 19:30:13 +0100
commit7179392e2b70c97109fced64eae72c1ee7cda87b (patch)
treec30e74f6c72ebc562b2dc25b1c7bbe73d5ea51b6
parent61a0347315951e48fd18e8f18690af79017c6fe8 (diff)
downloadastroid-git-7179392e2b70c97109fced64eae72c1ee7cda87b.tar.gz
Adds a test for property setter
-rw-r--r--tests/unittest_inference.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py
index e580ee2a..c107eadb 100644
--- a/tests/unittest_inference.py
+++ b/tests/unittest_inference.py
@@ -5494,14 +5494,19 @@ def test_property_inference():
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
)
@@ -5519,6 +5524,10 @@ def test_property_inference():
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)