Christian Heimes | 126d29a | 2008-02-11 22:57:17 +0000 | [diff] [blame] | 1 | import pickle |
Tim Peters | 8ecfc8e | 2003-01-27 18:51:48 +0000 | [diff] [blame] | 2 | import pickletools |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 3 | from test import support |
Christian Heimes | 126d29a | 2008-02-11 22:57:17 +0000 | [diff] [blame] | 4 | from test.pickletester import AbstractPickleTests |
| 5 | from test.pickletester import AbstractPickleModuleTests |
| 6 | |
| 7 | class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests): |
| 8 | |
Guido van Rossum | f416981 | 2008-03-17 22:56:06 +0000 | [diff] [blame] | 9 | def dumps(self, arg, proto=None): |
Christian Heimes | 126d29a | 2008-02-11 22:57:17 +0000 | [diff] [blame] | 10 | return pickletools.optimize(pickle.dumps(arg, proto)) |
| 11 | |
Alexander Belopolsky | ec8f0df | 2011-02-24 20:34:38 +0000 | [diff] [blame] | 12 | def loads(self, buf, **kwds): |
| 13 | return pickle.loads(buf, **kwds) |
Christian Heimes | 126d29a | 2008-02-11 22:57:17 +0000 | [diff] [blame] | 14 | |
Antoine Pitrou | d9dfaa9 | 2009-06-04 20:32:06 +0000 | [diff] [blame] | 15 | # Test relies on precise output of dumps() |
| 16 | test_pickle_to_2x = None |
| 17 | |
Christian Heimes | 126d29a | 2008-02-11 22:57:17 +0000 | [diff] [blame] | 18 | |
| 19 | def test_main(): |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 20 | support.run_unittest(OptimizedPickleTests) |
| 21 | support.run_doctest(pickletools) |
Christian Heimes | 126d29a | 2008-02-11 22:57:17 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | if __name__ == "__main__": |
| 25 | test_main() |