Skip to content

Commit

Permalink
Move the unit test to unittest_brain because it needs six
Browse files Browse the repository at this point in the history
  • Loading branch information
hippo91 authored and Pierre-Sassoulas committed Feb 12, 2021
1 parent dc560d4 commit 6189473
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
28 changes: 28 additions & 0 deletions tests/unittest_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 0 additions & 28 deletions tests/unittest_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand Down

0 comments on commit 6189473

Please sign in to comment.