[pypy-issue] Issue #2092: assertCountEqual gets wrong answer with list of tuples (pypy/pypy)

Ned Batchelder issues-reply at bitbucket.org
Wed Jul 22 01:43:31 CEST 2015


New issue 2092: assertCountEqual gets wrong answer with list of tuples
https://bitbucket.org/pypy/pypy/issues/2092/assertcountequal-gets-wrong-answer-with

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)
```




More information about the pypy-issue mailing list