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.

Author vitaly
Recipients docs@python, michael.foord, terry.reedy, vitaly
Date 2016-05-20.23:37:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463787479.81.0.99120597078.issue27060@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks Terry, your assessment is correct. The maintainers appear to have drawn the wrong conclusion in #17866, which mislead me about the existing assertItemsEqual in 2.7, which appears to work correctly after all!

import unittest as u
class Test(u.TestCase):
    def test_equal_count_of_same_elements(self):
        self.assertItemsEqual([1,2,3], [1,2,3])

    def test_equal_count_of_different_elements(self):
        self.assertItemsEqual([1,2,3], [1,2,4])

    def test_different_count(self):
        self.assertItemsEqual([1,2,3], [1,2,3,4])
u.main()


$ python assert_items_equal_test.py --verbose
test_different_count (__main__.Test) ... FAIL
test_equal_count_of_different_elements (__main__.Test) ... FAIL
test_equal_count_of_same_elements (__main__.Test) ... ok

======================================================================
FAIL: test_different_count (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "assert_items_equal_test.py", line 12, in test_different_count
    self.assertItemsEqual([1,2,3], [1,2,3,4])
AssertionError: Element counts were not equal:
First has 0, Second has 1:  4

======================================================================
FAIL: test_equal_count_of_different_elements (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "assert_items_equal_test.py", line 8, in test_equal_count_of_different_elements
    self.assertItemsEqual([1,2,3], [1,2,4])
AssertionError: Element counts were not equal:
First has 1, Second has 0:  3
First has 0, Second has 1:  4

----------------------------------------------------------------------
Ran 3 tests in 0.001s

FAILED (failures=2)
History
Date User Action Args
2016-05-20 23:37:59vitalysetrecipients: + vitaly, terry.reedy, michael.foord, docs@python
2016-05-20 23:37:59vitalysetmessageid: <1463787479.81.0.99120597078.issue27060@psf.upfronthosting.co.za>
2016-05-20 23:37:59vitalylinkissue27060 messages
2016-05-20 23:37:59vitalycreate