Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
018e1b7a
Commit
018e1b7a
authored
Jan 24, 2018
by
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి)
Committed by
INADA Naoki
Jan 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32360: unittest.util: Use Counter instead of custom count function (GH-4994)
parent
b7a80d54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
9 deletions
+2
-9
Lib/unittest/util.py
Lib/unittest/util.py
+2
-9
No files found.
Lib/unittest/util.py
View file @
018e1b7a
"""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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment