mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	 23cbd8a656
			
		
	
	
		23cbd8a656
		
	
	
	
	
		
			
			planned for the package. There are no docs yet, but they are coming once the API for the first new function, importlib.import_module() is finalized.
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			817 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			817 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import sys
 | |
| import unittest
 | |
| import importlib
 | |
| from .. import support
 | |
| 
 | |
| 
 | |
| class ParentModuleTests(unittest.TestCase):
 | |
| 
 | |
|     """Importing a submodule should import the parent modules."""
 | |
| 
 | |
|     def test_import_parent(self):
 | |
|         with support.mock_modules('pkg.__init__', 'pkg.module') as mock:
 | |
|             with support.import_state(meta_path=[mock]):
 | |
|                 module = support.import_('pkg.module')
 | |
|                 self.assert_('pkg' in sys.modules)
 | |
| 
 | |
|     def test_bad_parent(self):
 | |
|         with support.mock_modules('pkg.module') as mock:
 | |
|             with support.import_state(meta_path=[mock]):
 | |
|                 self.assertRaises(ImportError, support.import_, 'pkg.module')
 | |
| 
 | |
| 
 | |
| def test_main():
 | |
|     from test.support import run_unittest
 | |
|     run_unittest(ParentModuleTests)
 | |
| 
 | |
| 
 | |
| if __name__ == '__main__':
 | |
|     test_main()
 |