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

Method test_bad_newobj_args

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

Source from the content-addressed store, hash-verified

1835 f'when serializing {REX.__module__}.REX object'])
1836
1837 def test_bad_newobj_args(self):
1838 obj = REX((copyreg.__newobj__, ()))
1839 for proto in protocols[2:]:
1840 with self.subTest(proto=proto):
1841 with self.assertRaises((IndexError, pickle.PicklingError)) as cm:
1842 self.dumps(obj, proto)
1843 self.assertIn(str(cm.exception), {
1844 'tuple index out of range',
1845 '__newobj__ expected at least 1 argument, got 0'})
1846 self.assertEqual(cm.exception.__notes__, [
1847 f'when serializing {REX.__module__}.REX object'])
1848
1849 obj = REX((copyreg.__newobj__, [REX]))
1850 for proto in protocols[2:]:
1851 with self.subTest(proto=proto):
1852 with self.assertRaises(pickle.PicklingError) as cm:
1853 self.dumps(obj, proto)
1854 self.assertEqual(str(cm.exception),
1855 'second item of the tuple returned by __reduce__ '
1856 'must be a tuple, not list')
1857 self.assertEqual(cm.exception.__notes__, [
1858 f'when serializing {REX.__module__}.REX object'])
1859
1860 def test_bad_newobj_class(self):
1861 obj = REX((copyreg.__newobj__, (NoNew(),)))

Callers

nothing calls this directly

Calls 7

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