summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-02-25 00:22:36 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-02-25 00:22:36 (GMT)
commit6f73874edd30afaa9580f63d3ba0f1ea9c4b09b7 (patch)
tree2f0e2d2ca36b96315439cc3fbe6c87aeb9abc548 /Lib/test/test_descr.py
parentb0800dc53bdcb77b6fb7c07645460b7954792290 (diff)
downloadcpython-6f73874edd30afaa9580f63d3ba0f1ea9c4b09b7.zip
cpython-6f73874edd30afaa9580f63d3ba0f1ea9c4b09b7.tar.gz
cpython-6f73874edd30afaa9580f63d3ba0f1ea9c4b09b7.tar.bz2
Close #14095: type.__new__() doesn't remove __qualname__ key from the class
dict anymore if the key is present. Reject also non-string qualified names. And fix reference leaks in type.__new__().
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 7b9a523..d64af69 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4474,6 +4474,16 @@ order (MRO) for bases """
self.assertEqual(float.real.__qualname__, 'float.real')
self.assertEqual(int.__add__.__qualname__, 'int.__add__')
+ def test_qualname_dict(self):
+ ns = {'__qualname__': 'some.name'}
+ tp = type('Foo', (), ns)
+ self.assertEqual(tp.__qualname__, 'some.name')
+ self.assertEqual(tp.__dict__['__qualname__'], 'some.name')
+ self.assertEqual(ns, {'__qualname__': 'some.name'})
+
+ ns = {'__qualname__': 1}
+ self.assertRaises(TypeError, type, 'Foo', (), ns)
+
class DictProxyTests(unittest.TestCase):
def setUp(self):
@@ -4491,7 +4501,7 @@ class DictProxyTests(unittest.TestCase):
keys = list(it)
keys.sort()
self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
- '__weakref__', 'meth'])
+ '__qualname__', '__weakref__', 'meth'])
@unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
'trace function introduces __local__')
@@ -4500,7 +4510,7 @@ class DictProxyTests(unittest.TestCase):
it = self.C.__dict__.values()
self.assertNotIsInstance(it, list)
values = list(it)
- self.assertEqual(len(values), 5)
+ self.assertEqual(len(values), 6)
@unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
'trace function introduces __local__')
@@ -4511,7 +4521,7 @@ class DictProxyTests(unittest.TestCase):
keys = [item[0] for item in it]
keys.sort()
self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
- '__weakref__', 'meth'])
+ '__qualname__', '__weakref__', 'meth'])
def test_dict_type_with_metaclass(self):
# Testing type of __dict__ when metaclass set...