Esempio n. 1
0
 def test_definemodulealias(self):
     context = ConfigurationContext()
     from zope.modulealias.metaconfigure import alias_module
     alias_module(module='unittest', alias='unittest_alias',
                  context=context)
     self.assert_('unittest_alias' in sys.modules.keys())
     self.assertEqual(sys.modules['unittest_alias'],sys.modules['unittest'])
Esempio n. 2
0
 def test_samemodule_doesntfail(self):
     context = ConfigurationContext()
     from zope.modulealias.metaconfigure import alias_module
     self.assert_('math' in sys.modules)
     sys.modules['zope.modulealias.tests.test_modulealias.math'] = math
     alias_module(module='zope.modulealias.tests.test_modulealias.math',
                  alias='math',
                  context=context)
Esempio n. 3
0
 def test_module_not_imported(self):
     context = ConfigurationContext()
     from zope.modulealias.metaconfigure import alias_module
     m1 = 'zope.modulealias.tests.dummymodule'
     m2 = 'zope.modulealias.tests.dummymodule2'
     self.assert_(m1 not in sys.modules)
     alias_module(module=m1, alias=m2, context=context)
     self.assert_(m1 in sys.modules)
     self.assert_(sys.modules[m1] is sys.modules[m2])
     # Clean up after ourselves, so the test can be run in a loop:
     del sys.modules[m1]
     del sys.modules[m2]
     # Normal import causes the dummymodule to appear in the
     # package module as well, so remove it there, since
     # ConfigurationContext.resolve() will prefer that to
     # sys.modules.
     from zope.modulealias import tests
     del tests.dummymodule