@@ -892,10 +892,39 @@ def test_extractall_hardlink_on_symlink(self):
892892 self ._assert_on_file_content (hardlink_filepath , sha256_regtype )
893893
894894
895+ class GzipReadTestBase :
896+
897+ def test_read_with_extra_field (self ):
898+ with open (self .tarname , 'rb' ) as f :
899+ data = bytearray (f .read ())
900+ flags = data [3 ]
901+ self .assertEqual (flags , 8 )
902+ data [3 ] = flags | 4
903+ data [10 :10 ] = b'\x05 \x00 extra'
904+ with open (tmpname , 'wb' ) as f :
905+ f .write (data )
906+ print (self .mode )
907+ with tarfile .open (tmpname , mode = self .mode ):
908+ pass
909+
910+ def test_read_with_file_comment (self ):
911+ with open (self .tarname , 'rb' ) as f :
912+ data = bytearray (f .read ())
913+ flags = data [3 ]
914+ self .assertEqual (flags , 8 )
915+ data [3 ] = flags | 16
916+ i = data .index (0 , 10 ) + 1
917+ data [i :i ] = b'comment\x00 '
918+ with open (tmpname , 'wb' ) as f :
919+ f .write (data )
920+ with tarfile .open (tmpname , mode = self .mode ):
921+ pass
922+
923+
895924class MiscReadTest (MiscReadTestBase , unittest .TestCase ):
896925 test_fail_comp = None
897926
898- class GzipMiscReadTest (GzipTest , MiscReadTestBase , unittest .TestCase ):
927+ class GzipMiscReadTest (GzipTest , GzipReadTestBase , MiscReadTestBase , unittest .TestCase ):
899928 pass
900929
901930class Bz2MiscReadTest (Bz2Test , MiscReadTestBase , unittest .TestCase ):
@@ -969,7 +998,7 @@ def test_compare_members(self):
969998 finally :
970999 tar1 .close ()
9711000
972- class GzipStreamReadTest (GzipTest , StreamReadTest ):
1001+ class GzipStreamReadTest (GzipTest , GzipReadTestBase , StreamReadTest ):
9731002 pass
9741003
9751004class Bz2StreamReadTest (Bz2Test , StreamReadTest ):
0 commit comments