@@ -933,7 +933,10 @@ def test_tar_with_empty_directory(self):
933933 tar_data = tarfile .open (fileobj = archive )
934934 assert sorted (tar_data .getnames ()) == ['bar' , 'foo' ]
935935
936- @pytest .mark .skipif (IS_WINDOWS_PLATFORM , reason = 'No chmod on Windows' )
936+ @pytest .mark .skipif (
937+ IS_WINDOWS_PLATFORM or os .geteuid () == 0 ,
938+ reason = 'root user always has access ; no chmod on Windows'
939+ )
937940 def test_tar_with_inaccessible_file (self ):
938941 base = tempfile .mkdtemp ()
939942 full_path = os .path .join (base , 'foo' )
@@ -944,8 +947,9 @@ def test_tar_with_inaccessible_file(self):
944947 with pytest .raises (IOError ) as ei :
945948 tar (base )
946949
947- assert 'Can not access file in context: {}' .format (full_path ) in \
950+ assert 'Can not read file in context: {}' .format (full_path ) in (
948951 ei .exconly ()
952+ )
949953
950954 @pytest .mark .skipif (IS_WINDOWS_PLATFORM , reason = 'No symlinks on Windows' )
951955 def test_tar_with_file_symlinks (self ):
@@ -995,6 +999,18 @@ def test_tar_socket_file(self):
995999 tar_data = tarfile .open (fileobj = archive )
9961000 assert sorted (tar_data .getnames ()) == ['bar' , 'foo' ]
9971001
1002+ def tar_test_negative_mtime_bug (self ):
1003+ base = tempfile .mkdtemp ()
1004+ filename = os .path .join (base , 'th.txt' )
1005+ self .addCleanup (shutil .rmtree , base )
1006+ with open (filename , 'w' ) as f :
1007+ f .write ('Invisible Full Moon' )
1008+ os .utime (filename , (12345 , - 3600.0 ))
1009+ with tar (base ) as archive :
1010+ tar_data = tarfile .open (fileobj = archive )
1011+ assert tar_data .getnames () == ['th.txt' ]
1012+ assert tar_data .getmember ('th.txt' ).mtime == - 3600
1013+
9981014
9991015class ShouldCheckDirectoryTest (unittest .TestCase ):
10001016 exclude_patterns = [
0 commit comments