mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 02:15:10 +00:00 
			
		
		
		
	 21d3a32b99
			
		
	
	
		21d3a32b99
		
	
	
	
	
		
			
			and test_support.run_classtests() into run_unittest() and use it wherever possible. Also don't use "from test.test_support import ...", but "from test import test_support" in a few spots. From SF patch #662807.
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| # test_pickle dumps and loads pickles via pickle.py.
 | |
| # test_cpickle does the same, but via the cPickle module.
 | |
| # This test covers the other two cases, making pickles with one module and
 | |
| # loading them via the other.
 | |
| 
 | |
| import pickle
 | |
| import cPickle
 | |
| import unittest
 | |
| 
 | |
| from test import test_support
 | |
| from test.pickletester import AbstractPickleTests
 | |
| 
 | |
| class DumpCPickle_LoadPickle(AbstractPickleTests):
 | |
| 
 | |
|     error = KeyError
 | |
| 
 | |
|     def dumps(self, arg, proto=0, fast=0):
 | |
|         # Ignore fast
 | |
|         return cPickle.dumps(arg, proto)
 | |
| 
 | |
|     def loads(self, buf):
 | |
|         # Ignore fast
 | |
|         return pickle.loads(buf)
 | |
| 
 | |
| class DumpPickle_LoadCPickle(AbstractPickleTests):
 | |
| 
 | |
|     error = cPickle.BadPickleGet
 | |
| 
 | |
|     def dumps(self, arg, proto=0, fast=0):
 | |
|         # Ignore fast
 | |
|         return pickle.dumps(arg, proto)
 | |
| 
 | |
|     def loads(self, buf):
 | |
|         # Ignore fast
 | |
|         return cPickle.loads(buf)
 | |
| 
 | |
| def test_main():
 | |
|     test_support.run_unittest(
 | |
|         DumpCPickle_LoadPickle,
 | |
|         DumpPickle_LoadCPickle
 | |
|     )
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     test_main()
 |