blob: 3ffb74409dd3832cc01fdd7055aa8c877568b9d5 [file] [log] [blame]
Tim Petersc0c93702003-02-13 19:30:57 +00001# 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.
5
6import pickle
7import cPickle
Tim Petersc0c93702003-02-13 19:30:57 +00008
9from test import test_support
10from test.pickletester import AbstractPickleTests
11
12class DumpCPickle_LoadPickle(AbstractPickleTests):
13
14 error = KeyError
15
16 def dumps(self, arg, proto=0, fast=0):
17 # Ignore fast
18 return cPickle.dumps(arg, proto)
19
20 def loads(self, buf):
21 # Ignore fast
22 return pickle.loads(buf)
23
24class DumpPickle_LoadCPickle(AbstractPickleTests):
25
26 error = cPickle.BadPickleGet
27
28 def dumps(self, arg, proto=0, fast=0):
29 # Ignore fast
30 return pickle.dumps(arg, proto)
31
32 def loads(self, buf):
33 # Ignore fast
34 return cPickle.loads(buf)
35
36def test_main():
Walter Dörwald21d3a322003-05-01 17:45:56 +000037 test_support.run_unittest(
38 DumpCPickle_LoadPickle,
39 DumpPickle_LoadCPickle
40 )
Tim Petersc0c93702003-02-13 19:30:57 +000041
42if __name__ == "__main__":
43 test_main()