summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pickle.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-01-29 17:58:45 (GMT)
committerGuido van Rossum <guido@python.org>2003-01-29 17:58:45 (GMT)
commit5d9113d8be81596bc93f2b1a37f57e5110d39a77 (patch)
treef7bdf7fc9aa5afbf967e9e110baea0e4cdd9ffec /Lib/test/test_pickle.py
parentd3590f937f4493445beeb253e5048771d1663ab7 (diff)
downloadcpython-5d9113d8be81596bc93f2b1a37f57e5110d39a77.zip
cpython-5d9113d8be81596bc93f2b1a37f57e5110d39a77.tar.gz
cpython-5d9113d8be81596bc93f2b1a37f57e5110d39a77.tar.bz2
Implement appropriate __getnewargs__ for all immutable subclassable builtin
types. The special handling for these can now be removed from save_newobj(). Add some testing for this. Also add support for setting the 'fast' flag on the Python Pickler class, which suppresses use of the memo.
Diffstat (limited to 'Lib/test/test_pickle.py')
-rw-r--r--Lib/test/test_pickle.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index d30e084..8870904 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -11,9 +11,13 @@ from test.pickletester import AbstractPersistentPicklerTests
class PickleTests(AbstractPickleTests, AbstractPickleModuleTests, XXXTemp):
- def setUp(self):
- self.dumps = pickle.dumps
- self.loads = pickle.loads
+ def dumps(self, arg, proto=0, fast=0):
+ # Ignore fast
+ return pickle.dumps(arg, proto)
+
+ def loads(self, buf):
+ # Ignore fast
+ return pickle.loads(buf)
module = pickle
error = KeyError
@@ -22,9 +26,11 @@ class PicklerTests(AbstractPickleTests):
error = KeyError
- def dumps(self, arg, proto=0):
+ def dumps(self, arg, proto=0, fast=0):
f = StringIO()
p = pickle.Pickler(f, proto)
+ if fast:
+ p.fast = fast
p.dump(arg)
f.seek(0)
return f.read()
@@ -36,12 +42,14 @@ class PicklerTests(AbstractPickleTests):
class PersPicklerTests(AbstractPersistentPicklerTests):
- def dumps(self, arg, proto=0):
+ def dumps(self, arg, proto=0, fast=0):
class PersPickler(pickle.Pickler):
def persistent_id(subself, obj):
return self.persistent_id(obj)
f = StringIO()
p = PersPickler(f, proto)
+ if fast:
+ p.fast = fast
p.dump(arg)
f.seek(0)
return f.read()