mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Merged revisions 76196 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76196 | antoine.pitrou | 2009-11-10 21:49:30 +0100 (mar., 10 nov. 2009) | 8 lines Issue #7197: Allow unittest.TextTestRunner objects to be pickled and unpickled. This fixes crashes under Windows when trying to run test_multiprocessing in verbose mode. Additionally, Test_TextTestRunner hadn't been enabled in test_unittest. ........
This commit is contained in:
		
							parent
							
								
									adf6a6c842
								
							
						
					
					
						commit
						c63ecee6c3
					
				
					 3 changed files with 19 additions and 1 deletions
				
			
		|  | @ -17,6 +17,7 @@ | ||||||
| import types | import types | ||||||
| from copy import deepcopy | from copy import deepcopy | ||||||
| import io | import io | ||||||
|  | import pickle | ||||||
| 
 | 
 | ||||||
| ### Support code | ### Support code | ||||||
| ################################################################ | ################################################################ | ||||||
|  | @ -3441,6 +3442,17 @@ def _makeResult(self): | ||||||
|         expected = ['startTestRun', 'stopTestRun'] |         expected = ['startTestRun', 'stopTestRun'] | ||||||
|         self.assertEqual(events, expected) |         self.assertEqual(events, expected) | ||||||
| 
 | 
 | ||||||
|  |     def test_pickle_unpickle(self): | ||||||
|  |         # Issue #7197: a TextTestRunner should be (un)pickleable. This is | ||||||
|  |         # required by test_multiprocessing under Windows (in verbose mode). | ||||||
|  |         stream = io.StringIO("foo") | ||||||
|  |         runner = unittest.TextTestRunner(stream) | ||||||
|  |         for protocol in range(2, pickle.HIGHEST_PROTOCOL + 1): | ||||||
|  |             s = pickle.dumps(runner, protocol) | ||||||
|  |             obj = pickle.loads(s) | ||||||
|  |             # StringIO objects never compare equal, a cheap test instead. | ||||||
|  |             self.assertEqual(obj.stream.getvalue(), stream.getvalue()) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class TestDiscovery(TestCase): | class TestDiscovery(TestCase): | ||||||
| 
 | 
 | ||||||
|  | @ -3729,7 +3741,7 @@ def test_main(): | ||||||
|     support.run_unittest(Test_TestCase, Test_TestLoader, |     support.run_unittest(Test_TestCase, Test_TestLoader, | ||||||
|         Test_TestSuite, Test_TestResult, Test_FunctionTestCase, |         Test_TestSuite, Test_TestResult, Test_FunctionTestCase, | ||||||
|         Test_TestSkipping, Test_Assertions, TestLongMessage, |         Test_TestSkipping, Test_Assertions, TestLongMessage, | ||||||
|         Test_TestProgram, TestCleanUp, TestDiscovery) |         Test_TestProgram, TestCleanUp, TestDiscovery, Test_TextTestRunner) | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     test_main() |     test_main() | ||||||
|  |  | ||||||
|  | @ -12,6 +12,8 @@ def __init__(self,stream): | ||||||
|         self.stream = stream |         self.stream = stream | ||||||
| 
 | 
 | ||||||
|     def __getattr__(self, attr): |     def __getattr__(self, attr): | ||||||
|  |         if attr in ('stream', '__getstate__'): | ||||||
|  |             raise AttributeError(attr) | ||||||
|         return getattr(self.stream,attr) |         return getattr(self.stream,attr) | ||||||
| 
 | 
 | ||||||
|     def writeln(self, arg=None): |     def writeln(self, arg=None): | ||||||
|  |  | ||||||
|  | @ -123,6 +123,10 @@ C-API | ||||||
| Library | Library | ||||||
| ------- | ------- | ||||||
| 
 | 
 | ||||||
|  | - Issue #7197: Allow unittest.TextTestRunner objects to be pickled and | ||||||
|  |   unpickled. This fixes crashes under Windows when trying to run | ||||||
|  |   test_multiprocessing in verbose mode. | ||||||
|  | 
 | ||||||
| - Issue #3001: Add a C implementation of recursive locks which is used by | - Issue #3001: Add a C implementation of recursive locks which is used by | ||||||
|   default when instantiating a `threading.RLock` object. This makes  |   default when instantiating a `threading.RLock` object. This makes  | ||||||
|   recursive locks as fast as regular non-recursive locks (previously, |   recursive locks as fast as regular non-recursive locks (previously, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Antoine Pitrou
						Antoine Pitrou