mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Improve Counter.__repr__() to not fail with unorderable values
This commit is contained in:
parent
0115fae8c2
commit
4e6bf41934
2 changed files with 12 additions and 2 deletions
|
@ -893,6 +893,12 @@ class TestCounter(unittest.TestCase):
|
|||
c.subtract('aaaabbcce')
|
||||
self.assertEqual(c, Counter(a=-1, b=0, c=-1, d=1, e=-1))
|
||||
|
||||
def test_repr_nonsortable(self):
|
||||
c = Counter(a=2, b=None)
|
||||
r = repr(c)
|
||||
self.assertIn("'a': 2", r)
|
||||
self.assertIn("'b': None", r)
|
||||
|
||||
def test_helper_function(self):
|
||||
# two paths, one for real dicts and one for other mappings
|
||||
elems = list('abracadabra')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue