Пример #1
0
 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'
     )
Пример #2
0
 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'
     )
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
 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')
Пример #6
0
 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')
Пример #7
0
 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')
Пример #8
0
 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)
Пример #9
0
 def test_cached_module(self):
     """Modules already in the cache should be reused"""
     self.assertTrue(modules.load('%s:has_been_mutated' % __name__))
Пример #10
0
 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')
Пример #11
0
 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)
Пример #12
0
 def test_cached_module(self):
     """Modules already in the cache should be reused"""
     self.assertTrue(modules.load('%s:has_been_mutated' % __name__))