1import pickle 2import pickletools 3from test import test_support 4from test.pickletester import AbstractPickleTests 5from test.pickletester import AbstractPickleModuleTests 6 7class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests): 8 9 def dumps(self, arg, proto=0, fast=0): 10 return pickletools.optimize(pickle.dumps(arg, proto)) 11 12 def loads(self, buf): 13 return pickle.loads(buf) 14 15 module = pickle 16 error = KeyError 17 18def test_main(): 19 test_support.run_unittest(OptimizedPickleTests) 20 test_support.run_doctest(pickletools) 21 22 23if __name__ == "__main__": 24 test_main() 25