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

Method test_bad_newobj_class

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

Source from the content-addressed store, hash-verified

1858 f'when serializing {REX.__module__}.REX object'])
1859
1860 def test_bad_newobj_class(self):
1861 obj = REX((copyreg.__newobj__, (NoNew(),)))
1862 for proto in protocols[2:]:
1863 with self.subTest(proto=proto):
1864 with self.assertRaises(pickle.PicklingError) as cm:
1865 self.dumps(obj, proto)
1866 self.assertIn(str(cm.exception), {
1867 'first argument to __newobj__() has no __new__',
1868 f'first argument to __newobj__() must be a class, not {NoNew.__module__}.NoNew'})
1869 self.assertEqual(cm.exception.__notes__, [
1870 f'when serializing {REX.__module__}.REX object'])
1871
1872 def test_wrong_newobj_class(self):
1873 obj = REX((copyreg.__newobj__, (str,)))

Callers

nothing calls this directly

Calls 8

REXClass · 0.85
NoNewClass · 0.85
strFunction · 0.85
assertInMethod · 0.80
subTestMethod · 0.45
assertRaisesMethod · 0.45
dumpsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected