diff options
| author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-11-19 08:26:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-19 08:26:41 +0100 |
| commit | 96ca4dc75aacaba4d1f4e9a66a72699c9fc93349 (patch) | |
| tree | c88d6a5db37f6d93014938e3143def926cf7234d /tests | |
| parent | b07eb62466ae54bb0209d9253b7018a5d4c764e2 (diff) | |
| download | astroid-git-96ca4dc75aacaba4d1f4e9a66a72699c9fc93349.tar.gz | |
Add ``InferenceContext`` to ``ClassModel`` (#1257)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unittest_regrtest.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/unittest_regrtest.py b/tests/unittest_regrtest.py index f3300411..c7321dc1 100644 --- a/tests/unittest_regrtest.py +++ b/tests/unittest_regrtest.py @@ -24,7 +24,7 @@ import unittest import pytest -from astroid import MANAGER, Instance, nodes, test_utils +from astroid import MANAGER, Instance, nodes, parse, test_utils from astroid.builder import AstroidBuilder, extract_node from astroid.const import PY38_PLUS from astroid.exceptions import InferenceError @@ -379,5 +379,25 @@ def test_crash_in_dunder_inference_prevented() -> None: assert inferred.qname() == "builtins.dict.__delitem__" +def test_regression_crash_classmethod() -> None: + """Regression test for a crash reported in https://github.com/PyCQA/pylint/issues/4982""" + code = """ + class Base: + @classmethod + def get_first_subclass(cls): + for subclass in cls.__subclasses__(): + return subclass + return object + + + subclass = Base.get_first_subclass() + + + class Another(subclass): + pass + """ + parse(code) + + if __name__ == "__main__": unittest.main() |
