def get_module(self): """Load the module for this challenge part""" module = try_import_module(self.module_name) if not module: click.echo(f"Could not find {e_error(self.module_name)}") return module
def test_import_module_with_cyclical_imports(self): with self.assertRaises(AttributeError): try_import_module( 'tests.test_utils.modules_for_test.cyclic_import_a')
def test_import_module_with_error(self): with self.assertRaises(ZeroDivisionError): try_import_module( 'tests.test_utils.modules_for_test.module_with_error')
def test_import_missing_module(self): module = try_import_module( 'tests.test_utils.modules_for_test.missing_module') self.assertIsNone(module)
def test_import_existing_module(self): module = try_import_module( 'tests.test_utils.modules_for_test.normal_module') self.assertIsNotNone(module) self.assertEqual(module.VALUE, 1)