diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unittest_inference.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py index 4dc785ab..751a4586 100644 --- a/tests/unittest_inference.py +++ b/tests/unittest_inference.py @@ -24,6 +24,7 @@ """ # pylint: disable=too-many-lines import platform +import textwrap from functools import partial import unittest from unittest.mock import patch @@ -5479,6 +5480,28 @@ def test_property_inference(): assert isinstance(inferred, nodes.FunctionDef) +def test_property_as_string(): + code = """ + class A: + @property + def test(self): + return 42 + + A.test #@ + """ + node = extract_node(code) + inferred = next(node.infer()) + assert isinstance(inferred, objects.Property) + property_body = textwrap.dedent( + """ + @property + def test(self): + return 42 + """ + ) + assert inferred.as_string().strip() == property_body.strip() + + def test_property_callable_inference(): code = """ class A: |
