summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2014-04-25 15:34:06 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2014-04-25 15:34:06 +0300
commitfdda5d29d6ec864bbb2fc151fe7155012c1079cc (patch)
tree05eda7b78e1be2eb99ec33d28599b915032e2fff
parent974ff96958174bab4708395d451497f4362d54a7 (diff)
downloadastroid-git-fdda5d29d6ec864bbb2fc151fe7155012c1079cc.tar.gz
Add tests for checking that YES is not leaked when retrieving the metaclass of a Class node.
-rw-r--r--test/unittest_python3.py10
-rw-r--r--test/unittest_scoped_nodes.py10
2 files changed, 20 insertions, 0 deletions
diff --git a/test/unittest_python3.py b/test/unittest_python3.py
index 9cdde1ff..a526b0c7 100644
--- a/test/unittest_python3.py
+++ b/test/unittest_python3.py
@@ -131,6 +131,16 @@ class Python3TC(TestCase):
self.assertEqual(metaclass.name, 'type')
@require_version('3.0')
+ def test_metaclass_yes_leak(self):
+ astroid = self.builder.string_build(dedent("""
+ from ab import ABCMeta
+
+ class Meta(metaclass=ABCMeta): pass
+ """))
+ klass = astroid['Meta']
+ self.assertFalse(klass.metaclass())
+
+ @require_version('3.0')
def test_metaclass_ancestors(self):
astroid = self.builder.string_build(dedent("""
from abc import ABCMeta
diff --git a/test/unittest_scoped_nodes.py b/test/unittest_scoped_nodes.py
index 6470f1bd..9d87feb8 100644
--- a/test/unittest_scoped_nodes.py
+++ b/test/unittest_scoped_nodes.py
@@ -716,6 +716,16 @@ def g2():
self.assertIsInstance(metaclass, scoped_nodes.Class)
self.assertEqual(metaclass.name, 'ABCMeta')
+ def test_metaclass_yes_leak(self):
+ astroid = abuilder.string_build(dedent("""
+ from ab import ABCMeta
+
+ class Meta(object):
+ __metaclass__ = ABCMeta
+ """))
+ klass = astroid['Meta']
+ self.assertFalse(klass.metaclass())
+
@require_version('2.7')
def test_newstyle_and_metaclass_good(self):
astroid = abuilder.string_build(dedent("""