summaryrefslogtreecommitdiff
path: root/tests/unittest_brain.py
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-04-21 20:03:28 +0200
committerGitHub <noreply@github.com>2021-04-21 20:03:28 +0200
commitf6c38faa430c681f6724c83080952aa400dac25f (patch)
tree53ff767089e5991609835df78b1e1587e6b763f5 /tests/unittest_brain.py
parent0d086fa241effd405654611f1afec30236ca9137 (diff)
downloadastroid-git-f6c38faa430c681f6724c83080952aa400dac25f.tar.gz
Fix crash when evaluating typing.NamedTuple (#956)
Diffstat (limited to 'tests/unittest_brain.py')
-rw-r--r--tests/unittest_brain.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py
index 7f81a0c5..34fb4d8f 100644
--- a/tests/unittest_brain.py
+++ b/tests/unittest_brain.py
@@ -1321,6 +1321,32 @@ class TypingBrain(unittest.TestCase):
const = next(class_attr.infer())
self.assertEqual(const.value, "class_attr")
+ def test_namedtuple_inferred_as_class(self):
+ node = builder.extract_node(
+ """
+ from typing import NamedTuple
+ NamedTuple
+ """
+ )
+ inferred = next(node.infer())
+ assert isinstance(inferred, nodes.ClassDef)
+ assert inferred.name == "NamedTuple"
+
+ def test_namedtuple_bug_pylint_4383(self):
+ """Inference of 'NamedTuple' function shouldn't cause InferenceError.
+
+ https://github.com/PyCQA/pylint/issues/4383
+ """
+ node = builder.extract_node(
+ """
+ if True:
+ def NamedTuple():
+ pass
+ NamedTuple
+ """
+ )
+ next(node.infer())
+
def test_typing_types(self):
ast_nodes = builder.extract_node(
"""