]> granicus.if.org Git - python/commitdiff
move SharedKeyTests to test_descr
authorBenjamin Peterson <benjamin@python.org>
Mon, 17 Mar 2014 21:20:12 +0000 (16:20 -0500)
committerBenjamin Peterson <benjamin@python.org>
Mon, 17 Mar 2014 21:20:12 +0000 (16:20 -0500)
Lib/test/test_descr.py
Lib/test/test_types.py

index 71d8609ab8c0a167f36d2a7d5620537439411985..8bb7d6a4742b9d6fc5112ac05908cb6a0d783a17 100644 (file)
@@ -4974,11 +4974,33 @@ class PicklingTests(unittest.TestCase):
                     self._assert_is_copy(obj, objcopy2)
 
 
+class SharedKeyTests(unittest.TestCase):
+
+    @support.cpython_only
+    def test_subclasses(self):
+        # Verify that subclasses can share keys (per PEP 412)
+        class A:
+            pass
+        class B(A):
+            pass
+
+        a, b = A(), B()
+        self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
+        self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
+        a.x, a.y, a.z, a.w = range(4)
+        self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
+        a2 = A()
+        self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2)))
+        self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
+        b.u, b.v, b.w, b.t = range(4)
+        self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({}))
+
+
 def test_main():
     # Run all local test cases, with PTypesLongInitTest first.
     support.run_unittest(PTypesLongInitTest, OperatorsTest,
                          ClassPropertiesAndMethods, DictProxyTests,
-                         MiscTests, PicklingTests)
+                         MiscTests, PicklingTests, SharedKeyTests)
 
 if __name__ == "__main__":
     test_main()
index 18e6b0a89c628db4c37e4f83cbaff4f75ccda66b..ec10752e6a2ae0eac233c1cdd9bf7cd8ed858b54 100644 (file)
@@ -1,6 +1,6 @@
 # Python test set -- part 6, built-in types
 
-from test.support import run_unittest, run_with_locale, cpython_only
+from test.support import run_unittest, run_with_locale
 import collections
 import pickle
 import locale
@@ -1170,31 +1170,9 @@ class SimpleNamespaceTests(unittest.TestCase):
             self.assertEqual(ns, ns_roundtrip, pname)
 
 
-class SharedKeyTests(unittest.TestCase):
-
-    @cpython_only
-    def test_subclasses(self):
-        # Verify that subclasses can share keys (per PEP 412)
-        class A:
-            pass
-        class B(A):
-            pass
-
-        a, b = A(), B()
-        self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
-        self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
-        a.x, a.y, a.z, a.w = range(4)
-        self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
-        a2 = A()
-        self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2)))
-        self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
-        b.u, b.v, b.w, b.t = range(4)
-        self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({}))
-
-
 def test_main():
     run_unittest(TypesTests, MappingProxyTests, ClassCreationTests,
-                 SimpleNamespaceTests, SharedKeyTests)
+                 SimpleNamespaceTests)
 
 if __name__ == '__main__':
     test_main()