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
1877c008
Commit
1877c008
authored
Jul 29, 2000
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exercise .readline() and .readlines(). More data is written to the
test file, too, so the methods have more work to do.
parent
d64efc00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
4 deletions
+28
-4
Lib/test/test_gzip.py
Lib/test/test_gzip.py
+28
-4
No files found.
Lib/test/test_gzip.py
View file @
1877c008
...
...
@@ -16,15 +16,39 @@ data2 = """/* zlibmodule.c -- gzip-compatible data compression */
/* See http://www.winimage.com/zLibDll for Windows */
"""
f
=
gzip
.
GzipFile
(
filename
,
'wb'
)
;
f
.
write
(
data1
)
;
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'wb'
)
;
f
.
write
(
data1
*
50
)
;
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'rb'
)
;
d
=
f
.
read
()
;
f
.
close
()
assert
d
==
data1
assert
d
==
data1
*
50
# Append to the previous file
f
=
gzip
.
GzipFile
(
filename
,
'ab'
)
;
f
.
write
(
data2
)
;
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'ab'
)
;
f
.
write
(
data2
*
15
)
;
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'rb'
)
;
d
=
f
.
read
()
;
f
.
close
()
assert
d
==
data1
+
data2
assert
d
==
(
data1
*
50
)
+
(
data2
*
15
)
# Try .readline() with varying line lengths
f
=
gzip
.
GzipFile
(
filename
,
'rb'
)
line_length
=
0
while
1
:
L
=
f
.
readline
(
line_length
)
if
L
==
""
and
line_length
!=
0
:
break
assert
len
(
L
)
<=
line_length
line_length
=
(
line_length
+
1
)
%
50
f
.
close
()
# Try .readlines()
f
=
gzip
.
GzipFile
(
filename
,
'rb'
)
L
=
f
.
readlines
()
f
.
close
()
f
=
gzip
.
GzipFile
(
filename
,
'rb'
)
while
1
:
L
=
f
.
readlines
(
150
)
if
L
==
[]:
break
f
.
close
()
os
.
unlink
(
filename
)
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