From 6189473d344dbffd72ff65d7bb7fd04351caedaf Mon Sep 17 00:00:00 2001 From: hippo91 Date: Thu, 11 Feb 2021 19:11:14 +0100 Subject: [PATCH] Move the unit test to unittest_brain because it needs six --- tests/unittest_brain.py | 28 ++++++++++++++++++++++++++++ tests/unittest_inference.py | 28 ---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py index 4528955099..d048066c3b 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -484,6 +484,34 @@ def test_from_submodule_imports(self): inferred = next(ast_node.infer()) self.assertIsInstance(inferred, nodes.FunctionDef) + def test_with_metaclass_subclasses_inheritance(self): + ast_node = builder.extract_node( + """ + class A(type): + def test(cls): + return cls + + class C: + pass + + import six + class B(six.with_metaclass(A, C)): + pass + + B #@ + """ + ) + inferred = next(ast_node.infer()) + self.assertIsInstance(inferred, nodes.ClassDef) + self.assertEqual(inferred.name, "B") + bases = inferred.bases + self.assertIsInstance(bases[0], nodes.Call) + ancestors = tuple(inferred.ancestors()) + self.assertIsInstance(ancestors[0], nodes.ClassDef) + self.assertEqual(ancestors[0].name, "C") + self.assertIsInstance(ancestors[1], nodes.ClassDef) + self.assertEqual(ancestors[1].name, "object") + @unittest.skipUnless( HAS_MULTIPROCESSING, diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py index 10dd49d7b8..c107eadb19 100644 --- a/tests/unittest_inference.py +++ b/tests/unittest_inference.py @@ -3793,34 +3793,6 @@ class B(six.with_metaclass(A)): self.assertIsInstance(inferred, nodes.ClassDef) self.assertEqual(inferred.name, "B") - def test_With_metaclass_subclasses_inheritance(self): - ast_node = extract_node( - """ - class A(type): - def test(cls): - return cls - - class C: - pass - - import six - class B(six.with_metaclass(A, C)): - pass - - B #@ - """ - ) - inferred = next(ast_node.infer()) - self.assertIsInstance(inferred, nodes.ClassDef) - self.assertEqual(inferred.name, "B") - bases = inferred.bases - self.assertIsInstance(bases[0], nodes.Call) - ancestors = tuple(inferred.ancestors()) - self.assertIsInstance(ancestors[0], nodes.ClassDef) - self.assertEqual(ancestors[0].name, "C") - self.assertIsInstance(ancestors[1], nodes.ClassDef) - self.assertEqual(ancestors[1].name, "object") - def test_With_metaclass_with_partial_imported_name(self): ast_node = extract_node( """