MCPcopy Index your code
hub / github.com/python/cpython / test_newobj_generic

Method test_newobj_generic

Lib/test/pickletester.py:3442–3460  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3440 self.assert_is_copy(x, y)
3441
3442 def test_newobj_generic(self):
3443 for proto in protocols:
3444 for C in myclasses:
3445 with self.subTest(proto=proto, C=C):
3446 if self.py_version < (3, 0) and proto < 2 and C in (MyInt, MyStr):
3447 self.skipTest('int and str subclasses are not interoperable with Python 2')
3448 if (3, 0) <= self.py_version < (3, 4) and proto < 2 and C in (MyStr, MyUnicode):
3449 self.skipTest('str subclasses are not interoperable with Python < 3.4')
3450 if self.py_version < (3, 15) and C == MyFrozenDict:
3451 self.skipTest('frozendict is not available on Python < 3.15')
3452 B = C.__base__
3453 x = C(C.sample)
3454 x.foo = 42
3455 s = self.dumps(x, proto)
3456 y = self.loads(s)
3457 detail = (proto, C, B, x, y, type(y))
3458 self.assert_is_copy(x, y) # XXX revisit
3459 self.assertEqual(B(x), B(y), detail)
3460 self.assertEqual(x.__dict__, y.__dict__, detail)
3461
3462 def test_newobj_proxies(self):
3463 # NEWOBJ should use the __class__ rather than the raw type

Callers

nothing calls this directly

Calls 8

skipTestMethod · 0.80
assert_is_copyMethod · 0.80
CClass · 0.70
BClass · 0.70
subTestMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected