PyXR

c:\python24\lib \ test \ test_xpickle.py



0001 # test_pickle dumps and loads pickles via pickle.py.
0002 # test_cpickle does the same, but via the cPickle module.
0003 # This test covers the other two cases, making pickles with one module and
0004 # loading them via the other.
0005 
0006 import pickle
0007 import cPickle
0008 import unittest
0009 
0010 from test import test_support
0011 from test.pickletester import AbstractPickleTests
0012 
0013 class DumpCPickle_LoadPickle(AbstractPickleTests):
0014 
0015     error = KeyError
0016 
0017     def dumps(self, arg, proto=0, fast=0):
0018         # Ignore fast
0019         return cPickle.dumps(arg, proto)
0020 
0021     def loads(self, buf):
0022         # Ignore fast
0023         return pickle.loads(buf)
0024 
0025 class DumpPickle_LoadCPickle(AbstractPickleTests):
0026 
0027     error = cPickle.BadPickleGet
0028 
0029     def dumps(self, arg, proto=0, fast=0):
0030         # Ignore fast
0031         return pickle.dumps(arg, proto)
0032 
0033     def loads(self, buf):
0034         # Ignore fast
0035         return cPickle.loads(buf)
0036 
0037 def test_main():
0038     test_support.run_unittest(
0039         DumpCPickle_LoadPickle,
0040         DumpPickle_LoadCPickle
0041     )
0042 
0043 if __name__ == "__main__":
0044     test_main()
0045 

Generated by PyXR 0.9.4
SourceForge.net Logo