mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	 ab91fdef1f
			
		
	
	
		ab91fdef1f
		
	
	
	
	
		
			
			svn+ssh://svn.python.org/python/branches/py3k ........ r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line convert old fail* assertions to assert* ........
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			883 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			883 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from .. import util
 | |
| from . import util as import_util
 | |
| import sys
 | |
| import unittest
 | |
| import importlib
 | |
| 
 | |
| 
 | |
| class ParentModuleTests(unittest.TestCase):
 | |
| 
 | |
|     """Importing a submodule should import the parent modules."""
 | |
| 
 | |
|     def test_import_parent(self):
 | |
|         with util.mock_modules('pkg.__init__', 'pkg.module') as mock:
 | |
|             with util.import_state(meta_path=[mock]):
 | |
|                 module = import_util.import_('pkg.module')
 | |
|                 self.assertTrue('pkg' in sys.modules)
 | |
| 
 | |
|     def test_bad_parent(self):
 | |
|         with util.mock_modules('pkg.module') as mock:
 | |
|             with util.import_state(meta_path=[mock]):
 | |
|                 self.assertRaises(ImportError,
 | |
|                                     import_util.import_, 'pkg.module')
 | |
| 
 | |
| 
 | |
| def test_main():
 | |
|     from test.support import run_unittest
 | |
|     run_unittest(ParentModuleTests)
 | |
| 
 | |
| 
 | |
| if __name__ == '__main__':
 | |
|     test_main()
 |