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

Method test_simple_newobj

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

Source from the content-addressed store, hash-verified

3623 self.assertGreaterEqual(num_additems, 2)
3624
3625 def test_simple_newobj(self):
3626 x = SimpleNewObj.__new__(SimpleNewObj, 0xface) # avoid __init__
3627 x.abc = 666
3628 for proto in protocols:
3629 with self.subTest(proto=proto):
3630 if self.py_version < (3, 0) and proto < 2:
3631 self.skipTest('int subclasses are not interoperable with Python 2')
3632 s = self.dumps(x, proto)
3633 if proto < 1:
3634 if self.py_version >= (3, 7):
3635 self.assertIn(b'\nI64206', s) # INT
3636 else: # for test_xpickle
3637 self.assertIn(b'64206', s) # INT or LONG
3638 else:
3639 self.assertIn(b'M\xce\xfa', s) # BININT2
3640 if not (self.py_version < (3, 5) and proto == 4):
3641 self.assertEqual(opcode_in_pickle(pickle.NEWOBJ, s),
3642 2 <= proto)
3643 self.assertFalse(opcode_in_pickle(pickle.NEWOBJ_EX, s))
3644 y = self.loads(s) # will raise TypeError if __init__ called
3645 self.assert_is_copy(x, y)
3646
3647 def test_complex_newobj(self):
3648 x = ComplexNewObj.__new__(ComplexNewObj, 0xface) # avoid __init__

Callers

nothing calls this directly

Calls 10

opcode_in_pickleFunction · 0.85
skipTestMethod · 0.80
assertInMethod · 0.80
assertFalseMethod · 0.80
assert_is_copyMethod · 0.80
__new__Method · 0.45
subTestMethod · 0.45
dumpsMethod · 0.45
assertEqualMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected