def test_import_function(): func = import_callable('loafer.utils.import_callable') assert callable(func) assert inspect.isfunction(func)
def test_error_on_non_callable(): with pytest.raises(ImportError): import_callable('loafer')
def test_error_on_module(): with pytest.raises(ImportError): import_callable('examples')
def test_error_on_invalid_name(): with pytest.raises(ImportError): import_callable('invalid-1234') with pytest.raises(ImportError): import_callable('')
def test_error_on_method_name(): with pytest.raises(ImportError): import_callable('unittest.mock.Mock.call_count')
def test_import_class(): klass = import_callable('loafer.exceptions.ProviderError') assert klass.__name__ == 'ProviderError' assert inspect.isclass(klass)