mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Issue 19713: Add PEP 451-related deprecations.
This commit is contained in:
		
							parent
							
								
									02b9f9d6bb
								
							
						
					
					
						commit
						1500d49c22
					
				
					 15 changed files with 4348 additions and 4047 deletions
				
			
		|  | @ -10,6 +10,7 @@ | |||
| from test import support | ||||
| import types | ||||
| import unittest | ||||
| import warnings | ||||
| 
 | ||||
| 
 | ||||
| @contextmanager | ||||
|  | @ -143,7 +144,9 @@ def test_sys_modules(self): | |||
|             loader = 'a loader!' | ||||
|             module.__loader__ = loader | ||||
|             sys.modules[name] = module | ||||
|             found = self.init.find_loader(name) | ||||
|             with warnings.catch_warnings(): | ||||
|                 warnings.simplefilter('ignore', DeprecationWarning) | ||||
|                 found = self.init.find_loader(name) | ||||
|             self.assertEqual(loader, found) | ||||
| 
 | ||||
|     def test_sys_modules_loader_is_None(self): | ||||
|  | @ -154,7 +157,9 @@ def test_sys_modules_loader_is_None(self): | |||
|             module.__loader__ = None | ||||
|             sys.modules[name] = module | ||||
|             with self.assertRaises(ValueError): | ||||
|                 self.init.find_loader(name) | ||||
|                 with warnings.catch_warnings(): | ||||
|                     warnings.simplefilter('ignore', DeprecationWarning) | ||||
|                     self.init.find_loader(name) | ||||
| 
 | ||||
|     def test_sys_modules_loader_is_not_set(self): | ||||
|         # Should raise ValueError | ||||
|  | @ -168,14 +173,18 @@ def test_sys_modules_loader_is_not_set(self): | |||
|                 pass | ||||
|             sys.modules[name] = module | ||||
|             with self.assertRaises(ValueError): | ||||
|                 self.init.find_loader(name) | ||||
|                 with warnings.catch_warnings(): | ||||
|                     warnings.simplefilter('ignore', DeprecationWarning) | ||||
|                     self.init.find_loader(name) | ||||
| 
 | ||||
|     def test_success(self): | ||||
|         # Return the loader found on sys.meta_path. | ||||
|         name = 'some_mod' | ||||
|         with util.uncache(name): | ||||
|             with util.import_state(meta_path=[self.FakeMetaFinder]): | ||||
|                 self.assertEqual((name, None), self.init.find_loader(name)) | ||||
|                 with warnings.catch_warnings(): | ||||
|                     warnings.simplefilter('ignore', DeprecationWarning) | ||||
|                     self.assertEqual((name, None), self.init.find_loader(name)) | ||||
| 
 | ||||
|     def test_success_path(self): | ||||
|         # Searching on a path should work. | ||||
|  | @ -183,12 +192,16 @@ def test_success_path(self): | |||
|         path = 'path to some place' | ||||
|         with util.uncache(name): | ||||
|             with util.import_state(meta_path=[self.FakeMetaFinder]): | ||||
|                 self.assertEqual((name, path), | ||||
|                                  self.init.find_loader(name, path)) | ||||
|                 with warnings.catch_warnings(): | ||||
|                     warnings.simplefilter('ignore', DeprecationWarning) | ||||
|                     self.assertEqual((name, path), | ||||
|                                      self.init.find_loader(name, path)) | ||||
| 
 | ||||
|     def test_nothing(self): | ||||
|         # None is returned upon failure to find a loader. | ||||
|         self.assertIsNone(self.init.find_loader('nevergoingtofindthismodule')) | ||||
|         with warnings.catch_warnings(): | ||||
|             warnings.simplefilter('ignore', DeprecationWarning) | ||||
|             self.assertIsNone(self.init.find_loader('nevergoingtofindthismodule')) | ||||
| 
 | ||||
| class Frozen_FindLoaderTests(FindLoaderTests, unittest.TestCase): | ||||
|     init = frozen_init | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Eric Snow
						Eric Snow