assertCountEqual gets wrong answer with list of tuples
Created originally on Bitbucket by ned (Ned Batchelder)
With PyPy 3.2.5 (pypy 2.4.0.final.0), this code passes the first assertCountEqual, but fails on the second:
import unittest
d = [tuple(t) for t in [[1, 2], [3, -1], [2, 3], [-1, 1]]]
tc = unittest.TestCase()
tc.assertCountEqual(
[(1, 2), (3, -1), (2, 3), (-1, 1)],
[(-1, 1), (1, 2), (2, 3), (3, -1)]
)
tc.assertCountEqual(
d,
[(-1, 1), (1, 2), (2, 3), (3, -1)]
)
Output:
$ .tox/pypy3_24/bin/python foo.py
Traceback (most recent call last):
File "foo.py", line 12, in <module>
[(-1, 1), (1, 2), (2, 3), (3, -1)]
File "/usr/local/pythonz/pythons/PyPy3-2.4.0/lib-python/3/unittest/case.py", line 1028, in assertCountEqual
self.fail(msg)
File "/usr/local/pythonz/pythons/PyPy3-2.4.0/lib-python/3/unittest/case.py", line 494, in fail
raise self.failureException(msg)
AssertionError: Element counts were not equal:
First has 1, Second has 0: (3, -1)
First has 1, Second has 0: (-1, 1)
First has 0, Second has 1: (-1, 1)
First has 0, Second has 1: (3, -1)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information