Ejemplo n.º 1
0
    def test_load_class_attribute_error(self):
        class Stateless():
            pass

        mock_module = mock.MagicMock(spec=Stateless)
        with mock.patch.dict('sys.modules', test_module=mock_module):
            with self.assertRaises(AttributeError):
                Utils.load_class('test_module.test_classname')
Ejemplo n.º 2
0
    def test_load_class_import_error(self):
        def throw(*args, **kwargs):
            # pylint: disable=unused-argument
            # These arguments are used by the call to __import__
            raise ImportError()

        with mock.patch('builtins.__import__', side_effect=throw):
            with self.assertRaises(ImportError):
                Utils.load_class('test.class.please.ignore')
Ejemplo n.º 3
0
def loader(name, framework, environment, options):
    # alter the name to correctly find the class e.g. go from shaker to Shaker
    class_name = name.title()
    cls = Utils.load_class('harbinger.executors.' + name + '.' + class_name +
                           'Executor')
    framework_executor = cls(framework, environment, options)
    framework_executor.setup()
Ejemplo n.º 4
0
 def test_load_class(self):
     mock_module = mock.MagicMock()
     mock_module.test_classname = "test_classname"
     with mock.patch.dict('sys.modules', test_module=mock_module):
         self.assertEqual('test_classname',
                          Utils.load_class('test_module.test_classname'))