| 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 |