This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unittest's assertItemsEqual() method gives wrong order in error output
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Kylotan, python-dev, r.david.murray
Priority: normal Keywords:

Created on 2012-05-16 16:47 by Kylotan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg160887 - (view) Author: (Kylotan) Date: 2012-05-16 16:47
I have the following line in a unit test in 2.7.3:

    self.assertItemsEqual(['a', 'b', 'c'], ['a', 'b', 'c', 'd'])

I expect this output:

    AssertionError: Element counts were not equal:
    First has 0, Second has 1:  'd'

Instead I get this output:

    AssertionError: Element counts were not equal:
    First has 1, Second has 0:  'd'

I would expect 'First' to refer to the first sequence I pass to assertItemsEqual, not the second, and vice versa.

(Obviously in a trivial example like this it appears unimportant, but when debugging why a test has failed, the unexpected ordering can cause problems.)
msg160900 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-16 18:01
New changeset ff52583a5576 by R David Murray in branch '2.7':
#14832: 'first' now really refers to first arg in unittest assertItemsEqual
http://hg.python.org/cpython/rev/ff52583a5576
msg160901 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-05-16 18:02
Thanks, fixed.  Appears to have been a mistake made when we refactored from expected/actual to first/second.
History
Date User Action Args
2022-04-11 14:57:30adminsetgithub: 59037
2013-03-19 02:21:56r.david.murraylinkissue17459 superseder
2012-05-16 18:02:59r.david.murraysetstatus: open -> closed

type: behavior

nosy: + r.david.murray
messages: + msg160901
resolution: fixed
stage: resolved
2012-05-16 18:01:49python-devsetnosy: + python-dev
messages: + msg160900
2012-05-16 16:47:48Kylotancreate