mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	now that deepcopy can handle instance methods, this hack can be removed #7409
Thanks Robert Collins
This commit is contained in:
		
							parent
							
								
									a5076a2543
								
							
						
					
					
						commit
						d46430bd81
					
				
					 1 changed files with 2 additions and 13 deletions
				
			
		|  | @ -117,17 +117,6 @@ def __exit__(self, exc_type, exc_value, tb): | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class _AssertWrapper(object): |  | ||||||
|     """Wrap entries in the _type_equality_funcs registry to make them deep |  | ||||||
|     copyable.""" |  | ||||||
| 
 |  | ||||||
|     def __init__(self, function): |  | ||||||
|         self.function = function |  | ||||||
| 
 |  | ||||||
|     def __deepcopy__(self, memo): |  | ||||||
|         memo[id(self)] = self |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class TestCase(object): | class TestCase(object): | ||||||
|     """A class whose instances are single test cases. |     """A class whose instances are single test cases. | ||||||
| 
 | 
 | ||||||
|  | @ -201,7 +190,7 @@ def addTypeEqualityFunc(self, typeobj, function): | ||||||
|                     msg= argument that raises self.failureException with a |                     msg= argument that raises self.failureException with a | ||||||
|                     useful error message when the two arguments are not equal. |                     useful error message when the two arguments are not equal. | ||||||
|         """ |         """ | ||||||
|         self._type_equality_funcs[typeobj] = _AssertWrapper(function) |         self._type_equality_funcs[typeobj] = function | ||||||
| 
 | 
 | ||||||
|     def addCleanup(self, function, *args, **kwargs): |     def addCleanup(self, function, *args, **kwargs): | ||||||
|         """Add a function, with arguments, to be called when the test is |         """Add a function, with arguments, to be called when the test is | ||||||
|  | @ -424,7 +413,7 @@ def _getAssertEqualityFunc(self, first, second): | ||||||
|         if type(first) is type(second): |         if type(first) is type(second): | ||||||
|             asserter = self._type_equality_funcs.get(type(first)) |             asserter = self._type_equality_funcs.get(type(first)) | ||||||
|             if asserter is not None: |             if asserter is not None: | ||||||
|                 return asserter.function |                 return asserter | ||||||
| 
 | 
 | ||||||
|         return self._baseAssertEqual |         return self._baseAssertEqual | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson