Extract form validation error messages from HTTP responses for display when running tests #3996

Closed
opened 2025-12-29 18:32:31 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Aug 18, 2020).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

We have a custom assertHttpStatus() test method which simply compares the HTTP status of a received response to an expected value. A common scenario is to expect a 302 (redirect) response e.g. when creating a new object, but receive a 200 (OK) response when form validation fails. However, no further information about the failure is provided. We can extend this method to automatically extract and display relevant error messages.

Justification

Returning any detected form errors directly obviates the need for hacking on tests and re-running them to get more verbose output in response to a failure.

Originally created by @jeremystretch on GitHub (Aug 18, 2020). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes We have a custom `assertHttpStatus()` test method which simply compares the HTTP status of a received response to an expected value. A common scenario is to expect a 302 (redirect) response e.g. when creating a new object, but receive a 200 (OK) response when form validation fails. However, no further information about the failure is provided. We can extend this method to automatically extract and display relevant error messages. ### Justification Returning any detected form errors directly obviates the need for hacking on tests and re-running them to get more verbose output in response to a failure.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 18:32:31 +01:00
adam closed this issue 2025-12-29 18:32:31 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3996