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