Comment (by David):
Replying to [comment:1 Mariusz Felisiak]:
> This change would be backward incompatible because an output is
completely different. Moreover `assertCountEqual()` doesn't support
`maxDiff` (see #32469). I don't think it's worth changing.
The output will be different but is not true that it does not support for
maxDiff, since it is part of standard library and like other standard
methods uses the same truncation logic,
[[https://github.com/python/cpython/blob/a03a09e068435f47d02649dda93988dc44ffaaf1/Lib/unittest/case.py#L1199|
See source]].
Having a custom implementation of `assertCountEqual` in
`assertQuerysetEqual` would not be DRY. Also is much easier to understand
assertion output with unittests method than with the current
implementation.
--
Ticket URL: <https://code.djangoproject.com/ticket/33609#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by David):
To be more concise: this is the output with current implementation
{{{
Count[330 chars]': 1, 'Joe Smith 18': 1, 'Joe Smith 19': 1}) != Count[330
chars]': 1, 'Joe Smith 18': 1, 'Joe Smith 19': 1, 'Extra Person': 1})
Counter({'Joe Smith 0': 1,
'Joe Smith 1': 1,
'Joe Smith 2': 1,
'Joe Smith 3': 1,
'Joe Smith 4': 1,
'Joe Smith 5': 1,
'Joe Smith 6': 1,
'Joe Smith 7': 1,
'Joe Smith 8': 1,
'Joe Smith 9': 1,
'Joe Smith 10': 1,
'Joe Smith 11': 1,
'Joe Smith 12': 1,
'Joe Smith 13': 1,
'Joe Smith 14': 1,
'Joe Smith 15': 1,
'Joe Smith 16': 1,
'Joe Smith 17': 1,
'Joe Smith 18': 1,
- 'Joe Smith 19': 1})
? ^^
+ 'Joe Smith 19': 1,
? ^
+ 'Extra Person': 1})..
}}}
Versus this, which is the output for the same input with
`assertCountEqual`
{{{
Element counts were not equal:
First has 0, Second has 1: 'Extra Person'
}}}
And last the proof for maxDiff (I had to put 20 extra elements to be sure
it was generated):
{{{
# default maxDiff
Element counts were not equal:
Diff is 909 characters long. Set self.maxDiff to None to see it.
# maxDiff = None
Element counts were not equal:
First has 0, Second has 1: 'Extra Person 0'
First has 0, Second has 1: 'Extra Person 1'
First has 0, Second has 1: 'Extra Person 2'
First has 0, Second has 1: 'Extra Person 3'
First has 0, Second has 1: 'Extra Person 4'
First has 0, Second has 1: 'Extra Person 5'
First has 0, Second has 1: 'Extra Person 6'
First has 0, Second has 1: 'Extra Person 7'
First has 0, Second has 1: 'Extra Person 8'
First has 0, Second has 1: 'Extra Person 9'
First has 0, Second has 1: 'Extra Person 10'
First has 0, Second has 1: 'Extra Person 11'
First has 0, Second has 1: 'Extra Person 12'
First has 0, Second has 1: 'Extra Person 13'
First has 0, Second has 1: 'Extra Person 14'
First has 0, Second has 1: 'Extra Person 15'
First has 0, Second has 1: 'Extra Person 16'
First has 0, Second has 1: 'Extra Person 17'
First has 0, Second has 1: 'Extra Person 18'
First has 0, Second has 1: 'Extra Person 19'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33609#comment:3>
* cc: Nick Pope (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/33609#comment:4>