summaryrefslogtreecommitdiff
path: root/sys/lib/python/test/test_xpickle.py
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
commit458120dd40db6b4df55a4e96b650e16798ef06a0 (patch)
tree8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/lib/python/test/test_xpickle.py
parent3a742c699f6806c1145aea5149bf15de15a0afd7 (diff)
add hg and python
Diffstat (limited to 'sys/lib/python/test/test_xpickle.py')
-rw-r--r--sys/lib/python/test/test_xpickle.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/sys/lib/python/test/test_xpickle.py b/sys/lib/python/test/test_xpickle.py
new file mode 100644
index 000000000..42cd0f468
--- /dev/null
+++ b/sys/lib/python/test/test_xpickle.py
@@ -0,0 +1,44 @@
+# test_pickle dumps and loads pickles via pickle.py.
+# test_cpickle does the same, but via the cPickle module.
+# This test covers the other two cases, making pickles with one module and
+# loading them via the other.
+
+import pickle
+import cPickle
+import unittest
+
+from test import test_support
+from test.pickletester import AbstractPickleTests
+
+class DumpCPickle_LoadPickle(AbstractPickleTests):
+
+ error = KeyError
+
+ def dumps(self, arg, proto=0, fast=0):
+ # Ignore fast
+ return cPickle.dumps(arg, proto)
+
+ def loads(self, buf):
+ # Ignore fast
+ return pickle.loads(buf)
+
+class DumpPickle_LoadCPickle(AbstractPickleTests):
+
+ error = cPickle.BadPickleGet
+
+ def dumps(self, arg, proto=0, fast=0):
+ # Ignore fast
+ return pickle.dumps(arg, proto)
+
+ def loads(self, buf):
+ # Ignore fast
+ return cPickle.loads(buf)
+
+def test_main():
+ test_support.run_unittest(
+ DumpCPickle_LoadPickle,
+ DumpPickle_LoadCPickle
+ )
+
+if __name__ == "__main__":
+ test_main()