summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) <srinivasreddy@users.noreply.github.com>2018-01-24 07:49:58 (GMT)
committerINADA Naoki <methane@users.noreply.github.com>2018-01-24 07:49:58 (GMT)
commit018e1b7aad8d1a33ee14aae5c466d581d31e2369 (patch)
treea531494bb7b2ce517e959feb73de074ea2a4dcf5
parentb7a80d543e1e94475ab9c8214f7a9eab4e63c9ab (diff)
downloadcpython-018e1b7aad8d1a33ee14aae5c466d581d31e2369.zip
cpython-018e1b7aad8d1a33ee14aae5c466d581d31e2369.tar.gz
cpython-018e1b7aad8d1a33ee14aae5c466d581d31e2369.tar.bz2
bpo-32360: unittest.util: Use Counter instead of custom count function (GH-4994)
-rw-r--r--Lib/unittest/util.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/Lib/unittest/util.py b/Lib/unittest/util.py
index 45485dc..050eaed 100644
--- a/Lib/unittest/util.py
+++ b/Lib/unittest/util.py
@@ -1,6 +1,6 @@
"""Various utility functions."""
-from collections import namedtuple, OrderedDict
+from collections import namedtuple, Counter
from os.path import commonprefix
__unittest = True
@@ -153,17 +153,10 @@ def _count_diff_all_purpose(actual, expected):
result.append(diff)
return result
-def _ordered_count(iterable):
- 'Return dict of element counts, in the order they were first seen'
- c = OrderedDict()
- for elem in iterable:
- c[elem] = c.get(elem, 0) + 1
- return c
-
def _count_diff_hashable(actual, expected):
'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
# elements must be hashable
- s, t = _ordered_count(actual), _ordered_count(expected)
+ s, t = Counter(actual), Counter(expected)
result = []
for elem, cnt_s in s.items():
cnt_t = t.get(elem, 0)