From 1a14b5d2f6d7b16dcb8f50847b517798e8d1d759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:13:31 +0200 Subject: Decouple ``FunctionDef`` and ``Lambda`` (#2115) As discussed in #2112 we really need to decouple this nodes. --- tests/test_scoped_nodes.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') 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: -- cgit v1.2.1