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
f93b705b
Commit
f93b705b
authored
Jun 30, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #9239: add tests for modifying zipfile comments in append mode.
parents
24ef3e96
c399185f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
Lib/test/test_zipfile.py
Lib/test/test_zipfile.py
+18
-0
No files found.
Lib/test/test_zipfile.py
View file @
f93b705b
...
...
@@ -1134,6 +1134,24 @@ class OtherTests(unittest.TestCase):
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"r"
)
as
zipfr
:
self
.
assertEqual
(
zipfr
.
comment
,
comment2
)
# check that comments are correctly modified in append mode
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"w"
)
as
zipf
:
zipf
.
comment
=
b"original comment"
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"a"
)
as
zipf
:
zipf
.
comment
=
b"an updated comment"
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"r"
)
as
zipf
:
self
.
assertEqual
(
zipf
.
comment
,
b"an updated comment"
)
# check that comments are correctly shortened in append mode
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"w"
)
as
zipf
:
zipf
.
comment
=
b"original comment that's longer"
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"a"
)
as
zipf
:
zipf
.
comment
=
b"shorter comment"
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"r"
)
as
zipf
:
self
.
assertEqual
(
zipf
.
comment
,
b"shorter comment"
)
def
test_unicode_comment
(
self
):
with
zipfile
.
ZipFile
(
TESTFN
,
"w"
,
zipfile
.
ZIP_STORED
)
as
zipf
:
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
...
...
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