예제 #1
0
def test_import_function():
    func = import_callable('loafer.utils.import_callable')
    assert callable(func)
    assert inspect.isfunction(func)
예제 #2
0
def test_error_on_non_callable():
    with pytest.raises(ImportError):
        import_callable('loafer')
예제 #3
0
def test_error_on_module():
    with pytest.raises(ImportError):
        import_callable('examples')
예제 #4
0
def test_error_on_invalid_name():
    with pytest.raises(ImportError):
        import_callable('invalid-1234')

    with pytest.raises(ImportError):
        import_callable('')
예제 #5
0
def test_error_on_method_name():
    with pytest.raises(ImportError):
        import_callable('unittest.mock.Mock.call_count')
예제 #6
0
def test_import_class():
    klass = import_callable('loafer.exceptions.ProviderError')
    assert klass.__name__ == 'ProviderError'
    assert inspect.isclass(klass)