summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_scoped_nodes.py33
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: