def test_modname_load_specified(self): """When the specifier contains a module name, any provided default should be overridden""" self.assertEqual( modules.load( 'tests.target_module:specified_target', 'default_target'), 'SPECIFIED' )
def test_modname_load_default(self): """When the specifier contains no module name, any provided default should be used""" self.assertEqual( modules.load( 'tests.target_module', 'default_target'), 'DEFAULT' )
def get_emitters(self): emitters = [http_emitter] custom = [s.strip() for s in self.config.get('custom_emitters', '').split(',')] for emitter_spec in custom: if not emitter_spec: continue emitters.append(modules.load(emitter_spec, 'emitter')) return emitters
def test_pathname_load_finds_package(self): """"Loading modules by absolute path should correctly set the name of the loaded module to include any package containing it.""" m = modules.load(os.getcwd() + '/tests/target_module.py') self.assertEqual(m.__name__, 'tests.target_module')
def test_modname_load_specified(self): """When the specifier contains a module name, any provided default should be overridden""" self.assertEqual( modules.load('tests.target_module:specified_target', 'default_target'), 'SPECIFIED')
def test_modname_load_default(self): """When the specifier contains no module name, any provided default should be used""" self.assertEqual(modules.load('tests.target_module', 'default_target'), 'DEFAULT')
def test_cache_population(self): """Python module cache should be populated""" self.assertTrue('tests.target_module' not in sys.modules) modules.load('tests.target_module') self.assertTrue('tests.target_module' in sys.modules)
def test_cached_module(self): """Modules already in the cache should be reused""" self.assertTrue(modules.load('%s:has_been_mutated' % __name__))