mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Issue #13593: updating the importlib utility decorators for __qualname__.
This commit is contained in:
		
							parent
							
								
									c2f9874280
								
							
						
					
					
						commit
						96ff0840b6
					
				
					 2 changed files with 11 additions and 1 deletions
				
			
		|  | @ -111,7 +111,7 @@ def _write_atomic(path, data): | ||||||
| 
 | 
 | ||||||
| def _wrap(new, old): | def _wrap(new, old): | ||||||
|     """Simple substitute for functools.wraps.""" |     """Simple substitute for functools.wraps.""" | ||||||
|     for replace in ['__module__', '__name__', '__doc__']: |     for replace in ['__module__', '__name__', '__qualname__', '__doc__']: | ||||||
|         setattr(new, replace, getattr(old, replace)) |         setattr(new, replace, getattr(old, replace)) | ||||||
|     new.__dict__.update(old.__dict__) |     new.__dict__.update(old.__dict__) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -59,6 +59,11 @@ def test_reload_failure(self): | ||||||
|             self.raise_exception(name) |             self.raise_exception(name) | ||||||
|             self.assertIs(module, sys.modules[name]) |             self.assertIs(module, sys.modules[name]) | ||||||
| 
 | 
 | ||||||
|  |     def test_decorator_attrs(self): | ||||||
|  |         def fxn(self, module): pass | ||||||
|  |         wrapped = util.module_for_loader(fxn) | ||||||
|  |         self.assertEqual(wrapped.__name__, fxn.__name__) | ||||||
|  |         self.assertEqual(wrapped.__qualname__, fxn.__qualname__) | ||||||
| 
 | 
 | ||||||
| class SetPackageTests(unittest.TestCase): | class SetPackageTests(unittest.TestCase): | ||||||
| 
 | 
 | ||||||
|  | @ -108,6 +113,11 @@ def test_leaving_alone(self): | ||||||
|             module.__package__ = value |             module.__package__ = value | ||||||
|             self.verify(module, value) |             self.verify(module, value) | ||||||
| 
 | 
 | ||||||
|  |     def test_decorator_attrs(self): | ||||||
|  |         def fxn(module): pass | ||||||
|  |         wrapped = util.set_package(fxn) | ||||||
|  |         self.assertEqual(wrapped.__name__, fxn.__name__) | ||||||
|  |         self.assertEqual(wrapped.__qualname__, fxn.__qualname__) | ||||||
| 
 | 
 | ||||||
| def test_main(): | def test_main(): | ||||||
|     from test import support |     from test import support | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Meador Inge
						Meador Inge