mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	* Remove deprecated classes from pkgutil * Remove some other PEP 302 obsolescence * Use find_spec instead of load_module * Remove more tests of PEP 302 obsolete APIs * Remove another bunch of tests using obsolete load_modules() * Remove deleted names from __all__ * Remove obsolete footnote * imp is removed * Remove `imp` from generated stdlib names * What's new and blurb * Update zipimport documentation for the removed methods * Fix some Windows tests * Remove any test (or part of a test) that references `find_module()`. * Use assertIsNone() / assertIsNotNone() consistently. * Update Doc/reference/import.rst * We don't need pkgutil._get_spec() any more either * test.test_importlib.fixtures.NullFinder * ...BadLoaderFinder.find_module * ...test_api.InvalidatingNullFinder.find_module * ...test.test_zipimport test of z.find_module * Suppress cross-references to find_loader and find_module * Suppress cross-references to Finder * Suppress cross-references to pkgutil.ImpImporter and pkgutil.ImpLoader --------- Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			835 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			835 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from test.test_importlib import util
 | 
						|
 | 
						|
machinery = util.import_importlib('importlib.machinery')
 | 
						|
 | 
						|
import unittest
 | 
						|
 | 
						|
 | 
						|
class PathHookTest:
 | 
						|
 | 
						|
    """Test the path hook for source."""
 | 
						|
 | 
						|
    def path_hook(self):
 | 
						|
        return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader,
 | 
						|
            self.machinery.SOURCE_SUFFIXES))
 | 
						|
 | 
						|
    def test_success(self):
 | 
						|
        with util.create_modules('dummy') as mapping:
 | 
						|
            self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
 | 
						|
                                    'find_spec'))
 | 
						|
 | 
						|
    def test_empty_string(self):
 | 
						|
        # The empty string represents the cwd.
 | 
						|
        self.assertTrue(hasattr(self.path_hook()(''), 'find_spec'))
 | 
						|
 | 
						|
 | 
						|
(Frozen_PathHookTest,
 | 
						|
 Source_PathHooktest
 | 
						|
 ) = util.test_both(PathHookTest, machinery=machinery)
 | 
						|
 | 
						|
 | 
						|
if __name__ == '__main__':
 | 
						|
    unittest.main()
 |