Allow ValidationErrors to equal each other when created identically
Currently ValidationErrors (django.core.exceptions.ValidationError
) that have identical messages
don't equal each other, which is counter-intuitive, and can make certain kinds of testing more complicated. Please add an __eq__
method that allows two ValidationErrors to be compared.
Ideally, this would be more than just a simple self.messages == other.messages
. It would be most helpful if the comparison were independent of the order in which errors were raised in a field or in non_field_errors
.
Change History
(10)
Description: |
modified (diff)
|
Triage Stage: |
Unreviewed → Accepted
|
Owner: |
changed from nobody to caleb logan
|
Status: |
new → assigned
|
Has patch: |
set
|
Patch needs improvement: |
set
|
Owner: |
changed from caleb logan to David Smith
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Version: |
1.11 → master
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
I probably wouldn't want to limit the comparison to an error's message but rather to its full set of attributes (
message
,code
,params
). Whileparams
is always pushed intomessage
when iterating over the errors in anValidationError
, I believe it can be beneficial to know if the params that were put inside are the same.