symbian-qemu-0.9.1-12/python-2.6.1/Lib/test/test_xpickle.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     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.
       
     5 
       
     6 import pickle
       
     7 import cPickle
       
     8 
       
     9 from test import test_support
       
    10 from test.pickletester import AbstractPickleTests
       
    11 
       
    12 class 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 
       
    24 class 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 
       
    36 def test_main():
       
    37     test_support.run_unittest(
       
    38         DumpCPickle_LoadPickle,
       
    39         DumpPickle_LoadCPickle
       
    40     )
       
    41 
       
    42 if __name__ == "__main__":
       
    43     test_main()