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
d17ad8d6
Commit
d17ad8d6
authored
Jan 27, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stronger tests for combinatoric relationships.
parent
eb508ad8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
Lib/test/test_itertools.py
Lib/test/test_itertools.py
+5
-1
No files found.
Lib/test/test_itertools.py
View file @
d17ad8d6
...
...
@@ -285,11 +285,15 @@ class TestBasicOps(unittest.TestCase):
perm
=
list
(
permutations
(
s
,
r
))
comb
=
list
(
combinations
(
s
,
r
))
self
.
assertEquals
(
len
(
prod
),
len
(
s
)
**
r
)
self
.
assertEquals
(
prod
,
sorted
(
set
(
prod
)))
# prod in lexicographic order without repeats
self
.
assertEquals
(
cwr
,
[
t
for
t
in
prod
if
sorted
(
t
)
==
list
(
t
)])
# cwr: prods which are sorted
self
.
assertEquals
(
perm
,
[
t
for
t
in
prod
if
len
(
set
(
t
))
==
r
])
# perm: prods with no dups
self
.
assertEqual
(
comb
,
[
t
for
t
in
perm
if
sorted
(
t
)
==
list
(
t
)])
# comb: perms that are sorted
self
.
assertEqual
(
comb
,
[
t
for
t
in
cwr
if
len
(
set
(
t
))
==
r
])
# comb: cwrs without dups
self
.
assertEqual
(
set
(
comb
),
set
(
cwr
)
&
set
(
perm
))
# comb: both a cwr and a perm
self
.
assertEqual
(
comb
,
list
(
filter
(
set
(
cwr
).
__contains__
,
perm
)))
# comb: perm that is a cwr
self
.
assertEqual
(
comb
,
list
(
filter
(
set
(
perm
).
__contains__
,
cwr
)))
# comb: cwr that is a perm
self
.
assertEqual
(
comb
,
sorted
(
set
(
cwr
)
&
set
(
perm
)))
# comb: both a cwr and a perm
def
test_compress
(
self
):
self
.
assertEqual
(
list
(
compress
(
'ABCDEF'
,
[
1
,
0
,
1
,
0
,
1
,
1
])),
list
(
'ACEF'
))
...
...
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