def test_formerror(client): with current_app.test_request_context('/'): form = LoginUserForm(data={"username": "******", "password": "******"}) form.validate() error = FormError("username", "error message") error.populate_form(form) assert form.errors == {"username": ["error message"]}
def test_formerror_existing_field(client): with current_app.test_request_context('/'): form = LoginUserForm() form.validate() error = FormError("username", "error message") error.populate_form(form) assert form.errors["username"] == [ "You must provide a user name", "error message", ]