From 7f1d5134d89aab9b3e49030676637debfd731dbb Mon Sep 17 00:00:00 2001 From: Tim Martin Date: Wed, 7 Oct 2020 18:44:48 +0100 Subject: Fix incorrect MRO being calculated for scoped multiple inheritance If a class inherits from two bases and the classes are expressed as a non-trivial expression such as qualified with a module name, classes after the first could not be inferred due to reusing the context object in _inferred_bases --- tests/unittest_scoped_nodes.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py index c4597fa6..2606fd47 100644 --- a/tests/unittest_scoped_nodes.py +++ b/tests/unittest_scoped_nodes.py @@ -1417,6 +1417,30 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase): ], ) + def test_mro_with_attribute_classes(self): + cls = builder.extract_node( + """ + class A: + pass + class B: + pass + scope = object() + scope.A = A + scope.B = B + class C(scope.A, scope.B): + pass + """ + ) + self.assertEqualMro( + cls, + [ + "C", + "A", + "B", + "object" + ] + ) + def test_generator_from_infer_call_result_parent(self): func = builder.extract_node( """ -- cgit v1.2.1