Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit692260e

Browse files
committed
Test for zip64 more thoroughly
1 parente166f27 commit692260e

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

‎Lib/test/test_zipfile/test_core.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,22 +1149,24 @@ class LzmaWriterTests(AbstractWriterTests, unittest.TestCase):
11491149

11501150
classAbstractRemoveTests:
11511151

1152-
def_test_removing_members(self,test_files,indexes):
1152+
def_test_removing_members(self,test_files,indexes,force_zip64=False):
11531153
"""Test underlying _remove_members() for removing members at given
11541154
indexes."""
11551155
# calculate the expected results
11561156
expected_files= []
11571157
withzipfile.ZipFile(TESTFN,'w',self.compression)aszh:
11581158
fori, (file,data)inenumerate(test_files):
11591159
ifinotinindexes:
1160-
zh.writestr(file,data)
1160+
withzh.open(file,'w',force_zip64=force_zip64)asfh:
1161+
fh.write(data)
11611162
expected_files.append(file)
11621163
expected_size=os.path.getsize(TESTFN)
11631164

11641165
# prepare the test zip
11651166
withzipfile.ZipFile(TESTFN,'w',self.compression)aszh:
11661167
forfile,dataintest_files:
1167-
zh.writestr(file,data)
1168+
withzh.open(file,'w',force_zip64=force_zip64)asfh:
1169+
fh.write(data)
11681170

11691171
# do the removal and check the result
11701172
withzipfile.ZipFile(TESTFN,'a',self.compression)aszh:
@@ -1337,30 +1339,13 @@ def test_verify(self):
13371339

13381340
deftest_zip64(self):
13391341
"""Test if members use zip64."""
1340-
file='datafile.txt'
1341-
file1='pre.txt'
1342-
file2='post.txt'
1343-
data=b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem'
1344-
data1=b'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
1345-
data2=b'Duis aute irure dolor in reprehenderit in voluptate velit esse'
1346-
withzipfile.ZipFile(TESTFN,'w',self.compression)aszh:
1347-
withzh.open(file1,'w',force_zip64=True)asfh:
1348-
fh.write(data1)
1349-
withzh.open(file2,'w',force_zip64=True)asfh:
1350-
fh.write(data2)
1351-
expected_size=os.path.getsize(TESTFN)
1342+
test_files= [
1343+
('pre.txt',b'Lorem ipsum dolor sit amet, consectetur adipiscing elit'),
1344+
('datafile',b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem'),
1345+
('post.txt',b'Duis aute irure dolor in reprehenderit in voluptate velit esse'),
1346+
]
13521347

1353-
withzipfile.ZipFile(TESTFN,'w',self.compression)aszh:
1354-
withzh.open(file1,'w',force_zip64=True)asfh:
1355-
fh.write(data1)
1356-
withzh.open(file,'w',force_zip64=True)asfh:
1357-
fh.write(data)
1358-
withzh.open(file2,'w',force_zip64=True)asfh:
1359-
fh.write(data2)
1360-
withzipfile.ZipFile(TESTFN,'a',self.compression)aszh:
1361-
zh.remove(file)
1362-
self.assertIsNone(zh.testzip())
1363-
self.assertEqual(os.path.getsize(TESTFN),expected_size)
1348+
self._test_removing_members(test_files, [1],force_zip64=True)
13641349

13651350
classStoredRemoveTests(AbstractRemoveTests,unittest.TestCase):
13661351
compression=zipfile.ZIP_STORED

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp