@@ -3470,54 +3470,6 @@ def test_execute_zip64(self):
34703470 self .assertIn (b'number in executable: 5' , output )
34713471
34723472
3473- class TestDataOffsetPrependedZip (unittest .TestCase ):
3474- """Test .data_offset on reading zip files with an executable prepended."""
3475-
3476- def setUp (self ):
3477- self .exe_zip = findfile ('exe_with_zip' , subdir = 'archivetestdata' )
3478- self .exe_zip64 = findfile ('exe_with_z64' , subdir = 'archivetestdata' )
3479-
3480- def _test_data_offset (self , name ):
3481- with zipfile .ZipFile (name ) as zipfp :
3482- self .assertEqual (zipfp .data_offset , 713 )
3483-
3484- def test_data_offset_with_exe_prepended (self ):
3485- self ._test_data_offset (self .exe_zip )
3486-
3487- def test_data_offset_with_exe_prepended_zip64 (self ):
3488- self ._test_data_offset (self .exe_zip64 )
3489-
3490- class TestDataOffsetZipWrite (unittest .TestCase ):
3491- """Test .data_offset for ZipFile opened in write mode."""
3492-
3493- def setUp (self ):
3494- os .mkdir (TESTFNDIR )
3495- self .addCleanup (rmtree , TESTFNDIR )
3496- self .test_path = os .path .join (TESTFNDIR , 'testoffset.zip' )
3497-
3498- def test_data_offset_write_no_prefix (self ):
3499- with io .BytesIO () as fp :
3500- with zipfile .ZipFile (fp , "w" ) as zipfp :
3501- self .assertEqual (zipfp .data_offset , 0 )
3502-
3503- def test_data_offset_write_with_prefix (self ):
3504- with io .BytesIO () as fp :
3505- fp .write (b"this is a prefix" )
3506- with zipfile .ZipFile (fp , "w" ) as zipfp :
3507- self .assertEqual (zipfp .data_offset , 16 )
3508-
3509- def test_data_offset_write_no_tell (self ):
3510- # The initializer in ZipFile checks if tell raises AttributeError or
3511- # OSError when creating a file in write mode when deducing the offset
3512- # of the beginning of zip data
3513- class NoTellBytesIO (io .BytesIO ):
3514- def tell (self ):
3515- raise OSError ("Unimplemented!" )
3516- with NoTellBytesIO () as fp :
3517- with zipfile .ZipFile (fp , "w" ) as zipfp :
3518- self .assertIs (zipfp .data_offset , None )
3519-
3520-
35213473class EncodedMetadataTests (unittest .TestCase ):
35223474 file_names = ['\u4e00 ' , '\u4e8c ' , '\u4e09 ' ] # Han 'one', 'two', 'three'
35233475 file_content = [
0 commit comments