Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d748399

Browse files
committed
merge 3.4
2 parents e380e09 + 2a60534 commit d748399

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

Lib/test/test_descr.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4974,11 +4974,33 @@ def __repr__(self):
49744974
self._assert_is_copy(obj, objcopy2)
49754975

49764976

4977+
class SharedKeyTests(unittest.TestCase):
4978+
4979+
@support.cpython_only
4980+
def test_subclasses(self):
4981+
# Verify that subclasses can share keys (per PEP 412)
4982+
class A:
4983+
pass
4984+
class B(A):
4985+
pass
4986+
4987+
a, b = A(), B()
4988+
self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
4989+
self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
4990+
a.x, a.y, a.z, a.w = range(4)
4991+
self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
4992+
a2 = A()
4993+
self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2)))
4994+
self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
4995+
b.u, b.v, b.w, b.t = range(4)
4996+
self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({}))
4997+
4998+
49774999
def test_main():
49785000
# Run all local test cases, with PTypesLongInitTest first.
49795001
support.run_unittest(PTypesLongInitTest, OperatorsTest,
49805002
ClassPropertiesAndMethods, DictProxyTests,
4981-
MiscTests, PicklingTests)
5003+
MiscTests, PicklingTests, SharedKeyTests)
49825004

49835005
if __name__ == "__main__":
49845006
test_main()

Lib/test/test_types.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Python test set -- part 6, built-in types
22

3-
from test.support import run_unittest, run_with_locale, cpython_only
3+
from test.support import run_unittest, run_with_locale
44
import collections
55
import pickle
66
import locale
@@ -1170,31 +1170,9 @@ def test_pickle(self):
11701170
self.assertEqual(ns, ns_roundtrip, pname)
11711171

11721172

1173-
class SharedKeyTests(unittest.TestCase):
1174-
1175-
@cpython_only
1176-
def test_subclasses(self):
1177-
# Verify that subclasses can share keys (per PEP 412)
1178-
class A:
1179-
pass
1180-
class B(A):
1181-
pass
1182-
1183-
a, b = A(), B()
1184-
self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
1185-
self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
1186-
a.x, a.y, a.z, a.w = range(4)
1187-
self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
1188-
a2 = A()
1189-
self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2)))
1190-
self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
1191-
b.u, b.v, b.w, b.t = range(4)
1192-
self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({}))
1193-
1194-
11951173
def test_main():
11961174
run_unittest(TypesTests, MappingProxyTests, ClassCreationTests,
1197-
SimpleNamespaceTests, SharedKeyTests)
1175+
SimpleNamespaceTests)
11981176

11991177
if __name__ == '__main__':
12001178
test_main()

0 commit comments

Comments
 (0)