def test_import_error(self): """ Tests that import error is raised for module that doesnt exist """ config = {} class_name = 'blah.wrong.doesntexist' loader = PluginLoader() with self.assertRaises(ImportError): loader.load(class_name, config)
def test_load(self): """ Tests that an instance of a class is returned from the loader with a configuration passed to the init method. """ config = {'a': 1, 'b': 2} class_name = 'fake_package.fake_module.FakePlugin' loader = PluginLoader() obj = loader.load(class_name, config) for key, value in config.iteritems(): self.assertEquals(value, getattr(obj, key))