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

Method test_newobj_proxies

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

Source from the content-addressed store, hash-verified

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
3464 classes = myclasses[:]
3465 # Cannot create weakproxies to these classes
3466 for c in (MyInt, MyLong, MyTuple):
3467 classes.remove(c)
3468 for proto in protocols:
3469 for C in classes:
3470 with self.subTest(proto=proto, C=C):
3471 if self.py_version < (3, 4) and proto < 3 and C in (MyStr, MyUnicode):
3472 self.skipTest('str subclasses are not interoperable with Python < 3.4')
3473 if self.py_version < (3, 15) and C == MyFrozenDict:
3474 self.skipTest('frozendict is not available on Python < 3.15')
3475 B = C.__base__
3476 x = C(C.sample)
3477 x.foo = 42
3478 p = weakref.proxy(x)
3479 s = self.dumps(p, proto)
3480 y = self.loads(s)
3481 self.assertEqual(type(y), type(x)) # rather than type(p)
3482 detail = (proto, C, B, x, y, type(y))
3483 self.assertEqual(B(x), B(y), detail)
3484 self.assertEqual(x.__dict__, y.__dict__, detail)
3485
3486 def test_newobj_overridden_new(self):
3487 # Test that Python class with C implemented __new__ is pickleable

Callers

nothing calls this directly

Calls 9

skipTestMethod · 0.80
proxyMethod · 0.80
CClass · 0.70
BClass · 0.70
removeMethod · 0.45
subTestMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected