diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-06 09:22:23 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-06 09:22:23 +0100 |
| commit | aaef3665b6dfbd7f46f2dac905d1c2efb3db3f97 (patch) | |
| tree | 89d6b1bf4697cfb7b628d8521faf40861caddcc3 /tests | |
| parent | 555085e0bd850c5381e29d15294cd37287f79bd6 (diff) | |
| download | astroid-git-aaef3665b6dfbd7f46f2dac905d1c2efb3db3f97.tar.gz | |
Add support for converting Property objects to strings
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: |
