summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-12-30 10:58:17 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2020-12-30 11:47:27 +0100
commit00ccda69584785fd22025a3f821e1c3437302eaa (patch)
tree95ba9abf3a4b4361a99a6a8a9fa12d1cae28d91e /tests
parent98fd2173be45a04df49735862b994e1c6c7028d2 (diff)
downloadastroid-git-00ccda69584785fd22025a3f821e1c3437302eaa.tar.gz
Fix a bug for dunder methods inference of function objects
Fixes #819
Diffstat (limited to 'tests')
-rw-r--r--tests/unittest_regrtest.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unittest_regrtest.py b/tests/unittest_regrtest.py
index 17668edd..b75e3dfe 100644
--- a/tests/unittest_regrtest.py
+++ b/tests/unittest_regrtest.py
@@ -343,5 +343,16 @@ def test_ancestor_looking_up_redefined_function():
assert isinstance(found[0], nodes.FunctionDef)
+def test_crash_in_dunder_inference_prevented():
+ code = """
+ class MyClass():
+ def fu(self, objects):
+ delitem = dict.__delitem__.__get__(self, dict)
+ delitem #@
+ """
+ inferred = next(extract_node(code).infer())
+ assert "builtins.dict.__delitem__" == inferred.qname()
+
+
if __name__ == "__main__":
unittest.main()