summaryrefslogtreecommitdiff
path: root/astroid/tests
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-04-18 20:50:46 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-04-18 20:50:46 +0300
commit2cab2395cf9dbee0d076d5f0b69b50aac8c0312e (patch)
treebfac072cb3230b05d051c7fffb8098945ddb6b46 /astroid/tests
parente7b8030955757b9746418644d5bc5f16306df148 (diff)
downloadastroid-2cab2395cf9dbee0d076d5f0b69b50aac8c0312e.tar.gz
Don't hard fail when calling .mro() on a class which has combined both newstyle and old style classes.
The class in question is actually newstyle (and the __mro__ can be retrieved using Python). .mro() fallbacks to using .ancestors() in that case.
Diffstat (limited to 'astroid/tests')
-rw-r--r--astroid/tests/unittest_scoped_nodes.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py
index b6bb7dc..2c18fbc 100644
--- a/astroid/tests/unittest_scoped_nodes.py
+++ b/astroid/tests/unittest_scoped_nodes.py
@@ -1154,6 +1154,23 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
self.assertEqual(str(cm.exception), "Could not obtain mro for "
"old-style classes.")
+ @test_utils.require_version(maxver='3.0')
+ def test_combined_newstyle_oldstyle_in_mro(self):
+ node = test_utils.extract_node('''
+ class Old:
+ pass
+ class New(object):
+ pass
+ class New1(object):
+ pass
+ class New2(New, New1):
+ pass
+ class NewOld(New2, Old): #@
+ pass
+ ''')
+ self.assertEqualMro(node, ['NewOld', 'New2', 'New', 'New1', 'object', 'Old'])
+ self.assertTrue(node.newstyle)
+
def test_with_metaclass_mro(self):
astroid = test_utils.build_module("""
import six