@@ -884,10 +884,39 @@ def test_extractall_hardlink_on_symlink(self):
884884 self ._assert_on_file_content (hardlink_filepath , sha256_regtype )
885885
886886
887+ class GzipReadTestBase :
888+
889+ def test_read_with_extra_field (self ):
890+ with open (self .tarname , 'rb' ) as f :
891+ data = bytearray (f .read ())
892+ flags = data [3 ]
893+ self .assertEqual (flags , 8 )
894+ data [3 ] = flags | 4
895+ data [10 :10 ] = b'\x05 \x00 extra'
896+ with open (tmpname , 'wb' ) as f :
897+ f .write (data )
898+ print (self .mode )
899+ with tarfile .open (tmpname , mode = self .mode ):
900+ pass
901+
902+ def test_read_with_file_comment (self ):
903+ with open (self .tarname , 'rb' ) as f :
904+ data = bytearray (f .read ())
905+ flags = data [3 ]
906+ self .assertEqual (flags , 8 )
907+ data [3 ] = flags | 16
908+ i = data .index (0 , 10 ) + 1
909+ data [i :i ] = b'comment\x00 '
910+ with open (tmpname , 'wb' ) as f :
911+ f .write (data )
912+ with tarfile .open (tmpname , mode = self .mode ):
913+ pass
914+
915+
887916class MiscReadTest (MiscReadTestBase , unittest .TestCase ):
888917 test_fail_comp = None
889918
890- class GzipMiscReadTest (GzipTest , MiscReadTestBase , unittest .TestCase ):
919+ class GzipMiscReadTest (GzipTest , GzipReadTestBase , MiscReadTestBase , unittest .TestCase ):
891920 pass
892921
893922class Bz2MiscReadTest (Bz2Test , MiscReadTestBase , unittest .TestCase ):
@@ -959,7 +988,7 @@ def test_compare_members(self):
959988 finally :
960989 tar1 .close ()
961990
962- class GzipStreamReadTest (GzipTest , StreamReadTest ):
991+ class GzipStreamReadTest (GzipTest , GzipReadTestBase , StreamReadTest ):
963992 pass
964993
965994class Bz2StreamReadTest (Bz2Test , StreamReadTest ):
0 commit comments