mirror of
				https://github.com/python/cpython.git
				synced 2025-11-01 06:01:29 +00:00 
			
		
		
		
	Issue #20804: The unittest.mock.sentinel attributes now preserve their
identity when they are copied or pickled.
This commit is contained in:
		
							parent
							
								
									d4f5001bac
								
							
						
					
					
						commit
						d9c956fb23
					
				
					 5 changed files with 33 additions and 0 deletions
				
			
		|  | @ -238,6 +238,9 @@ def __init__(self, name): | |||
|     def __repr__(self): | ||||
|         return 'sentinel.%s' % self.name | ||||
| 
 | ||||
|     def __reduce__(self): | ||||
|         return 'sentinel.%s' % self.name | ||||
| 
 | ||||
| 
 | ||||
| class _Sentinel(object): | ||||
|     """Access attributes to return a named object, usable as a sentinel.""" | ||||
|  | @ -250,6 +253,9 @@ def __getattr__(self, name): | |||
|             raise AttributeError | ||||
|         return self._sentinels.setdefault(name, _SentinelObject(name)) | ||||
| 
 | ||||
|     def __reduce__(self): | ||||
|         return 'sentinel' | ||||
| 
 | ||||
| 
 | ||||
| sentinel = _Sentinel() | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka