def test_user_defined_modules():
 class MockModule(object, ):
  def __init__(self, name):
   self.__name__ = name
  def __repr__(self):
   return (('MockModule("' + self.__name__) + '")')
 TopModule = MockModule('TopModule')
 sys.modules['TopModule'] = TopModule
 SubModule = MockModule('SubModule')
 theObj = object()
 SubModule.Object = theObj
 TopModule.SubModule = SubModule
 sys.modules['TopModule.SubModule'] = SubModule
 (x, y) = (TopModule, SubModule)
 del TopModule, SubModule
 import TopModule.SubModule
 AreEqual(TopModule, x)
 Assert(('SubModule' not in dir()))
 from TopModule.SubModule import Object
 AreEqual(Object, theObj)
 SubModule2 = MockModule('SubModule2')
 SubModule2.Object2 = theObj
 sys.modules['TopModule.SubModule'] = SubModule2
 from TopModule.SubModule import Object2
 AreEqual(Object2, theObj)
 del sys.modules['TopModule']
 del sys.modules['TopModule.SubModule']

def test_user_defined_modules ( ) : class MockModule ( object , ) : def __init__ ( self , name ) : self . __name__ = name def __repr__ ( self ) : return ( ( 'MockModule("' + self . __name__ ) + '")' ) TopModule = MockModule ( 'TopModule' ) sys . modules [ 'TopModule' ] = TopModule SubModule = MockModule ( 'SubModule' ) theObj = object ( ) SubModule . Object = theObj TopModule . SubModule = SubModule sys . modules [ 'TopModule.SubModule' ] = SubModule ( x , y ) = ( TopModule , SubModule ) del TopModule , SubModule import TopModule . SubModule AreEqual ( TopModule , x ) Assert ( ( 'SubModule' not in dir ( ) ) ) from TopModule . SubModule import Object AreEqual ( Object , theObj ) SubModule2 = MockModule ( 'SubModule2' ) SubModule2 . Object2 = theObj sys . modules [ 'TopModule.SubModule' ] = SubModule2 from TopModule . SubModule import Object2 AreEqual ( Object2 , theObj ) del sys . modules [ 'TopModule' ] del sys . modules [ 'TopModule.SubModule' ]
test the importer using user-defined module types .