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
ff5dc0ee
Commit
ff5dc0ee
authored
Sep 29, 2004
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test coverage.
parent
bcab2b25
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
Lib/test/test_enumerate.py
Lib/test/test_enumerate.py
+29
-0
Lib/test/test_itertools.py
Lib/test/test_itertools.py
+16
-0
No files found.
Lib/test/test_enumerate.py
View file @
ff5dc0ee
...
...
@@ -145,6 +145,35 @@ class TestReversed(unittest.TestCase):
# This is an implementation detail, not an interface requirement
for
s
in
(
'hello'
,
tuple
(
'hello'
),
list
(
'hello'
),
xrange
(
5
)):
self
.
assertEqual
(
len
(
reversed
(
s
)),
len
(
s
))
r
=
reversed
(
s
)
list
(
r
)
self
.
assertEqual
(
len
(
r
),
0
)
class
SeqWithWeirdLen
:
called
=
False
def
__len__
(
self
):
if
not
self
.
called
:
self
.
called
=
True
return
10
raise
ZeroDivisionError
def
__getitem__
(
self
,
index
):
return
index
r
=
reversed
(
SeqWithWeirdLen
())
self
.
assertRaises
(
ZeroDivisionError
,
len
,
r
)
def
test_gc
(
self
):
class
Seq
:
def
__len__
(
self
):
return
10
def
__getitem__
(
self
,
index
):
return
index
s
=
Seq
()
r
=
reversed
(
s
)
s
.
r
=
r
def
test_args
(
self
):
self
.
assertRaises
(
TypeError
,
reversed
)
self
.
assertRaises
(
TypeError
,
reversed
,
[],
'extra'
)
def
test_main
(
verbose
=
None
):
testclasses
=
(
EnumerateTestCase
,
SubclassTestCase
,
TestEmpty
,
TestBig
,
...
...
Lib/test/test_itertools.py
View file @
ff5dc0ee
...
...
@@ -420,6 +420,14 @@ class TestGC(unittest.TestCase):
a
=
[]
self
.
makecycle
(
cycle
([
a
]
*
2
),
a
)
def
test_dropwhile
(
self
):
a
=
[]
self
.
makecycle
(
dropwhile
(
bool
,
[
0
,
a
,
a
]),
a
)
def
test_groupby
(
self
):
a
=
[]
self
.
makecycle
(
groupby
([
a
]
*
2
,
lambda
x
:
x
),
a
)
def
test_ifilter
(
self
):
a
=
[]
self
.
makecycle
(
ifilter
(
lambda
x
:
True
,
[
a
]
*
2
),
a
)
...
...
@@ -440,10 +448,18 @@ class TestGC(unittest.TestCase):
a
=
[]
self
.
makecycle
(
islice
([
a
]
*
2
,
None
),
a
)
def
test_repeat
(
self
):
a
=
[]
self
.
makecycle
(
repeat
(
a
),
a
)
def
test_starmap
(
self
):
a
=
[]
self
.
makecycle
(
starmap
(
lambda
*
t
:
t
,
[(
a
,
a
)]
*
2
),
a
)
def
test_takewhile
(
self
):
a
=
[]
self
.
makecycle
(
takewhile
(
bool
,
[
1
,
0
,
a
,
a
]),
a
)
def
R
(
seqn
):
'Regular generator'
for
i
in
seqn
:
...
...
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