#1153769: document PEP 237 changes to string formatting.
[python.git] / Lib / test / test_xpickle.py
blob3ffb74409dd3832cc01fdd7055aa8c877568b9d5
1 # test_pickle dumps and loads pickles via pickle.py.
2 # test_cpickle does the same, but via the cPickle module.
3 # This test covers the other two cases, making pickles with one module and
4 # loading them via the other.
6 import pickle
7 import cPickle
9 from test import test_support
10 from test.pickletester import AbstractPickleTests
12 class DumpCPickle_LoadPickle(AbstractPickleTests):
14 error = KeyError
16 def dumps(self, arg, proto=0, fast=0):
17 # Ignore fast
18 return cPickle.dumps(arg, proto)
20 def loads(self, buf):
21 # Ignore fast
22 return pickle.loads(buf)
24 class DumpPickle_LoadCPickle(AbstractPickleTests):
26 error = cPickle.BadPickleGet
28 def dumps(self, arg, proto=0, fast=0):
29 # Ignore fast
30 return pickle.dumps(arg, proto)
32 def loads(self, buf):
33 # Ignore fast
34 return cPickle.loads(buf)
36 def test_main():
37 test_support.run_unittest(
38 DumpCPickle_LoadPickle,
39 DumpPickle_LoadCPickle
42 if __name__ == "__main__":
43 test_main()