def test_constructed_module():
 ModuleType = type(sys)
 TopModule = ModuleType('TopModule')
 sys.modules['TopModule'] = TopModule
 SubModule = ModuleType('SubModule')
 SubModule.Object = object()
 TopModule.SubModule = SubModule
 try:
  import TopModule.SubModule
  AssertUnreachable()
 except ImportError:
  pass
 del sys.modules['TopModule']

def test_constructed_module ( ) : ModuleType = type ( sys ) TopModule = ModuleType ( 'TopModule' ) sys . modules [ 'TopModule' ] = TopModule SubModule = ModuleType ( 'SubModule' ) SubModule . Object = object ( ) TopModule . SubModule = SubModule try : import TopModule . SubModule AssertUnreachable ( ) except ImportError : pass del sys . modules [ 'TopModule' ]
verify that we dont load arbitrary modules from modules .