##// END OF EJS Templates
Added sorting on counter and passed all tests
Jono Tassia -
Show More
@@ -918,7 +918,7 b' def _counter_pprint(obj, p, cycle):'
918 918 if cycle:
919 919 p.pretty(cls_ctor(RawText("...")))
920 920 elif len(obj):
921 p.pretty(cls_ctor(dict(obj)))
921 p.pretty(cls_ctor(dict(sorted(obj.items(), key=lambda x: x[1], reverse=True))))
922 922 else:
923 923 p.pretty(cls_ctor())
924 924
@@ -422,6 +422,7 b' def test_collections_counter():'
422 422 (Counter(), 'Counter()'),
423 423 (Counter(a=1), "Counter({'a': 1})"),
424 424 (MyCounter(a=1), "MyCounter({'a': 1})"),
425 (Counter(a=1, c=22), "Counter({'c': 22, 'a': 1})")
425 426 ]
426 427 for obj, expected in cases:
427 428 assert pretty.pretty(obj) == expected
General Comments 0
You need to be logged in to leave comments. Login now