diff options
author | Guido van Rossum <guido@python.org> | 2003-01-28 19:48:18 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-01-28 19:48:18 (GMT) |
commit | 3d8c01b31c1a58d2181f78c5df2b0e79131046c0 (patch) | |
tree | 956b7a7da9a7de221671bfc5d77749b27c17b5a4 /Lib/test/pickletester.py | |
parent | abcb0c03ade3cee52b71362f57b16af3e00c743b (diff) | |
download | cpython-3d8c01b31c1a58d2181f78c5df2b0e79131046c0.zip cpython-3d8c01b31c1a58d2181f78c5df2b0e79131046c0.tar.gz cpython-3d8c01b31c1a58d2181f78c5df2b0e79131046c0.tar.bz2 |
The default __reduce__ on the base object type obscured any
possibility of calling save_reduce(). Add a special hack for this.
The tests for this are much simpler now (no __getstate__ or
__getnewargs__ needed).
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r-- | Lib/test/pickletester.py | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index ea658bb..cc464a9 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -301,43 +301,34 @@ class AbstractPickleTests(unittest.TestCase): self.assert_(x is y, (proto, x, s, y)) def test_newobj_tuple(self): - x = MyTuple([1, 2, 3], foo=42, bar="hello") + x = MyTuple([1, 2, 3]) + x.foo = 42 + x.bar = "hello" s = self.dumps(x, 2) y = self.loads(s) self.assertEqual(tuple(x), tuple(y)) self.assertEqual(x.__dict__, y.__dict__) +## import pickletools +## print +## pickletools.dis(s) def test_newobj_list(self): - x = MyList([1, 2, 3], foo=42, bar="hello") + x = MyList([1, 2, 3]) + x.foo = 42 + x.bar = "hello" s = self.dumps(x, 2) y = self.loads(s) self.assertEqual(list(x), list(y)) self.assertEqual(x.__dict__, y.__dict__) +## import pickletools +## print +## pickletools.dis(s) class MyTuple(tuple): - def __new__(cls, *args, **kwds): - # Ignore **kwds - return tuple.__new__(cls, *args) - def __getnewargs__(self): - return (tuple(self),) - def __init__(self, *args, **kwds): - for k, v in kwds.items(): - setattr(self, k, v) + pass class MyList(list): - def __new__(cls, *args, **kwds): - # Ignore **kwds - return list.__new__(cls, *args) - def __init__(self, *args, **kwds): - for k, v in kwds.items(): - setattr(self, k, v) - def __getstate__(self): - return list(self), self.__dict__ - def __setstate__(self, arg): - lst, dct = arg - for x in lst: - self.append(x) - self.__init__(**dct) + pass class AbstractPickleModuleTests(unittest.TestCase): |