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.
Created on 2013年03月18日 13:48 by Zr40, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg184452 - (view) | Author: Matthijs van der Vleuten (Zr40) | Date: 2013年03月18日 13:48 | |
When calling assertItemsEqual(first,second), if the items in a and b differ, the AssertionError treats second as the first sequence and first as the second sequence. Repro code: >>> from unittest.case import TestCase >>> class Foo(TestCase): ... def runTest(self): ... self.assertItemsEqual([1],[]) ... >>> Foo().runTest() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in runTest File "/usr/lib/python2.7/unittest/case.py", line 899, in assertItemsEqual self.fail(msg) File "/usr/lib/python2.7/unittest/case.py", line 408, in fail raise self.failureException(msg) AssertionError: Element counts were not equal: First has 0, Second has 1: 1 This happens because of this code in unittest/case.py: def assertItemsEqual(self, expected_seq, actual_seq, msg=None): # (skip docstring) first_seq, second_seq = list(actual_seq), list(expected_seq) list(actual_seq) is assigned to first_seq, even though it's actually the second argument. This would be fixed either by swapping expected_seq and actual_seq in the function's arguments, or swapping the assignment of first_seq and second_seq. |
|||
| msg184453 - (view) | Author: Matthijs van der Vleuten (Zr40) | Date: 2013年03月18日 13:54 | |
Duplicate of 14832. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:43 | admin | set | github: 61661 |
| 2013年03月19日 02:21:56 | r.david.murray | set | superseder: unittest's assertItemsEqual() method gives wrong order in error output resolution: duplicate stage: resolved |
| 2013年03月18日 13:54:09 | Zr40 | set | status: open -> closed messages: + msg184453 |
| 2013年03月18日 13:48:28 | Zr40 | create | |