def _create_password_validator(app): return compose( prepare( compose( lambda app: app.config.get('MUSERS_PASSWORD_VALIDATOR'), import_string ) ), catch(ImportError, _default_validator), catch(RuntimeError, _default_validator), get_or_reraise )(app)
def test_catch_return_data_when_no_error(): data = ('test', None) f = Mock() c = catch(Exception, f) result = c(data) assert not f.called assert result == data
def test_catch_given_error_and_call_function(): ex = Exception() data = (None, ex) f = Mock() c = catch(Exception, f) result = c(data) assert f.called assert f.call_args == call(ex) assert result[0] == f.return_value assert result[1] is None