def setup_backends(audio): backends = [] for backend_class_name in settings.BACKENDS: backend_class = importing.get_class(backend_class_name) backend = backend_class.start(audio=audio).proxy() backends.append(backend) return backends
def stop_frontends(): for frontend_class_name in settings.FRONTENDS: try: frontend_class = importing.get_class(frontend_class_name) process.stop_actors_by_class(frontend_class) except exceptions.OptionalDependencyError: pass
def setup_frontends(core): for frontend_class_name in settings.FRONTENDS: try: importing.get_class(frontend_class_name).start(core=core) except exceptions.OptionalDependencyError as ex: logger.info('Disabled: %s (%s)', frontend_class_name, ex)
def stop_backends(): for backend_class_name in settings.BACKENDS: process.stop_actors_by_class(importing.get_class(backend_class_name))
def test_loading_module_that_does_not_exist(self): with self.assertRaises(ImportError): importing.get_class('foo.bar.Baz')
def test_loading_existing_class(self): cls = importing.get_class('unittest.TestCase') self.assertEqual(cls.__name__, 'TestCase')
def test_import_error_message_contains_complete_class_path(self): try: importing.get_class('foo.bar.Baz') except ImportError as e: self.assertIn('foo.bar.Baz', str(e))
def test_loading_incorrect_class_path(self): with self.assertRaises(ImportError): importing.get_class('foobarbaz')
def test_loading_class_that_does_not_exist(self): with self.assertRaises(ImportError): importing.get_class('unittest.FooBarBaz')