Message265977
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) |
|
Date |
User |
Action |
Args |
2016-05-20 23:37:59 | vitaly | set | recipients:
+ vitaly, terry.reedy, michael.foord, docs@python |
2016-05-20 23:37:59 | vitaly | set | messageid: <1463787479.81.0.99120597078.issue27060@psf.upfronthosting.co.za> |
2016-05-20 23:37:59 | vitaly | link | issue27060 messages |
2016-05-20 23:37:59 | vitaly | create | |
|