Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 652
    • Issues 652
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • pypypypy
  • Issues
  • #2092

Closed
Open
Created Jul 21, 2015 by Bitbucket Importer@bitbucket_importerMaintainer

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
Assignee
Assign to
Time tracking