diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-06-16 09:12:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-16 09:12:43 +0200 |
commit | 5e9519dfb1364a69abeca44f80480237526d67e3 (patch) | |
tree | 0ed91652f9f41c46f94d9e4f7f7e520bd60f65c3 /tests/unittest_regrtest.py | |
parent | 03e2986682b429d1ffb1f017e34537ab4c8e2ac5 (diff) | |
download | astroid-git-2.4.tar.gz |
Fix a crash caused by a lookup of a monkey-patched method (#803)2.4
Close PyCQA/pylint#3686
Diffstat (limited to 'tests/unittest_regrtest.py')
-rw-r--r-- | tests/unittest_regrtest.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unittest_regrtest.py b/tests/unittest_regrtest.py index 7171941b..17668edd 100644 --- a/tests/unittest_regrtest.py +++ b/tests/unittest_regrtest.py @@ -324,5 +324,24 @@ class Whatever: a = property(lambda x: x, lambda x: x) +def test_ancestor_looking_up_redefined_function(): + code = """ + class Foo: + def _format(self): + pass + + def format(self): + self.format = self._format + self.format() + Foo + """ + node = extract_node(code) + inferred = next(node.infer()) + ancestor = next(inferred.ancestors()) + _, found = ancestor.lookup("format") + assert len(found) == 1 + assert isinstance(found[0], nodes.FunctionDef) + + if __name__ == "__main__": unittest.main() |