diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2023-04-17 17:13:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-17 17:13:31 +0200 |
commit | 1a14b5d2f6d7b16dcb8f50847b517798e8d1d759 (patch) | |
tree | 696f32917b1e03e369176f6989d52ecbd0c4ac8a /tests | |
parent | c40d6c0fcd83af530418f89749020352cc6f5b76 (diff) | |
download | astroid-git-1a14b5d2f6d7b16dcb8f50847b517798e8d1d759.tar.gz |
Decouple ``FunctionDef`` and ``Lambda`` (#2115)
As discussed in #2112 we really need to decouple this nodes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_scoped_nodes.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_scoped_nodes.py b/tests/test_scoped_nodes.py index 1a6b8d15..d3a890ab 100644 --- a/tests/test_scoped_nodes.py +++ b/tests/test_scoped_nodes.py @@ -930,6 +930,39 @@ class FunctionNodeTest(ModuleLoader, unittest.TestCase): func: nodes.FunctionDef = builder.extract_node(code) # type: ignore[assignment] assert func.doc_node is None + @staticmethod + def test_display_type() -> None: + code = textwrap.dedent( + """\ + def foo(): + bar = 1 + """ + ) + func: nodes.FunctionDef = builder.extract_node(code) # type: ignore[assignment] + assert func.display_type() == "Function" + + code = textwrap.dedent( + """\ + class A: + def foo(self): #@ + bar = 1 + """ + ) + func: nodes.FunctionDef = builder.extract_node(code) # type: ignore[assignment] + assert func.display_type() == "Method" + + @staticmethod + def test_inference_error() -> None: + code = textwrap.dedent( + """\ + def foo(): + bar = 1 + """ + ) + func: nodes.FunctionDef = builder.extract_node(code) # type: ignore[assignment] + with pytest.raises(AttributeInferenceError): + func.getattr("") + class ClassNodeTest(ModuleLoader, unittest.TestCase): def test_dict_interface(self) -> None: |