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
026a399b
Commit
026a399b
authored
Sep 23, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test_large_file_exception. Ported tests for large count of files
to AbstractTestZip64InSmallFiles.
parent
cfbb3944
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
1 deletion
+62
-1
Lib/test/test_zipfile.py
Lib/test/test_zipfile.py
+62
-1
No files found.
Lib/test/test_zipfile.py
View file @
026a399b
...
...
@@ -462,7 +462,9 @@ class AbstractTestZip64InSmallFiles:
def
setUp
(
self
):
self
.
_limit
=
zipfile
.
ZIP64_LIMIT
zipfile
.
ZIP64_LIMIT
=
5
self
.
_filecount_limit
=
zipfile
.
ZIP_FILECOUNT_LIMIT
zipfile
.
ZIP64_LIMIT
=
1000
zipfile
.
ZIP_FILECOUNT_LIMIT
=
9
# Make a source file with some lines
with
open
(
TESTFN
,
"wb"
)
as
fp
:
...
...
@@ -529,8 +531,67 @@ class AbstractTestZip64InSmallFiles:
for
f
in
get_files
(
self
):
self
.
zip_test
(
f
,
self
.
compression
)
def
test_too_many_files
(
self
):
# This test checks that more than 64k files can be added to an archive,
# and that the resulting archive can be read properly by ZipFile
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
"w"
,
self
.
compression
,
allowZip64
=
True
)
zipf
.
debug
=
100
numfiles
=
15
for
i
in
range
(
numfiles
):
zipf
.
writestr
(
"foo%08d"
%
i
,
"%d"
%
(
i
**
3
%
57
))
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
zipf
.
close
()
zipf2
=
zipfile
.
ZipFile
(
TESTFN
,
"r"
,
self
.
compression
)
self
.
assertEqual
(
len
(
zipf2
.
namelist
()),
numfiles
)
for
i
in
range
(
numfiles
):
content
=
zipf2
.
read
(
"foo%08d"
%
i
).
decode
(
'ascii'
)
self
.
assertEqual
(
content
,
"%d"
%
(
i
**
3
%
57
))
zipf2
.
close
()
def
test_too_many_files_append
(
self
):
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
"w"
,
self
.
compression
,
allowZip64
=
False
)
zipf
.
debug
=
100
numfiles
=
9
for
i
in
range
(
numfiles
):
zipf
.
writestr
(
"foo%08d"
%
i
,
"%d"
%
(
i
**
3
%
57
))
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
with
self
.
assertRaises
(
zipfile
.
LargeZipFile
):
zipf
.
writestr
(
"foo%08d"
%
numfiles
,
b''
)
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
zipf
.
close
()
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
"a"
,
self
.
compression
,
allowZip64
=
False
)
zipf
.
debug
=
100
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
with
self
.
assertRaises
(
zipfile
.
LargeZipFile
):
zipf
.
writestr
(
"foo%08d"
%
numfiles
,
b''
)
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
zipf
.
close
()
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
"a"
,
self
.
compression
,
allowZip64
=
True
)
zipf
.
debug
=
100
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
numfiles2
=
15
for
i
in
range
(
numfiles
,
numfiles2
):
zipf
.
writestr
(
"foo%08d"
%
i
,
"%d"
%
(
i
**
3
%
57
))
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles2
)
zipf
.
close
()
zipf2
=
zipfile
.
ZipFile
(
TESTFN
,
"r"
,
self
.
compression
)
self
.
assertEqual
(
len
(
zipf2
.
namelist
()),
numfiles2
)
for
i
in
range
(
numfiles2
):
content
=
zipf2
.
read
(
"foo%08d"
%
i
).
decode
(
'ascii'
)
self
.
assertEqual
(
content
,
"%d"
%
(
i
**
3
%
57
))
zipf2
.
close
()
def
tearDown
(
self
):
zipfile
.
ZIP64_LIMIT
=
self
.
_limit
zipfile
.
ZIP_FILECOUNT_LIMIT
=
self
.
_filecount_limit
unlink
(
TESTFN
)
unlink
(
TESTFN2
)
...
...
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