Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#28507 closed New feature (fixed)

Allow ValidationErrors to equal each other when created identically

Reported by: kamni Owned by: David Smith
Component: Core (Other) Version: dev
Severity: Normal Keywords: ValidationError
Cc: Markus Holtermann Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by kamni)

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)

comment:1 by kamni, 7 years ago

Description: modified (diff)

comment:2 by Markus Holtermann, 7 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Markus Holtermann, 7 years ago

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). While params is always pushed into message when iterating over the errors in an ValidationError, I believe it can be beneficial to know if the params that were put inside are the same.

comment:4 by caleb logan, 7 years ago

Owner: changed from nobody to caleb logan
Status: newassigned

comment:5 by Mariusz Felisiak, 5 years ago

Has patch: set
Patch needs improvement: set

comment:6 by David Smith, 4 years ago

Owner: changed from caleb logan to David Smith
Patch needs improvement: unset
Version 0, edited 4 years ago by David Smith (next)

comment:7 by Mariusz Felisiak, 4 years ago

Patch needs improvement: set

comment:8 by Mariusz Felisiak, 4 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin
Version: 1.11master

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 95da207:

Fixed #28507 -- Made ValidationError.eq() ignore messages and params ordering.

Co-authored-by: caleb logan <clogan202@…>

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 4c67552:

Refs #29838, Refs #28507 -- Made make_hashable() ignore key order.

Note: See TracTickets for help on using tickets.
Back to Top