@@ -933,7 +933,10 @@ def test_tar_with_empty_directory(self):
933
933
tar_data = tarfile .open (fileobj = archive )
934
934
assert sorted (tar_data .getnames ()) == ['bar' , 'foo' ]
935
935
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
+ )
937
940
def test_tar_with_inaccessible_file (self ):
938
941
base = tempfile .mkdtemp ()
939
942
full_path = os .path .join (base , 'foo' )
@@ -944,8 +947,9 @@ def test_tar_with_inaccessible_file(self):
944
947
with pytest .raises (IOError ) as ei :
945
948
tar (base )
946
949
947
- assert 'Can not access file in context: {}' .format (full_path ) in \
950
+ assert 'Can not read file in context: {}' .format (full_path ) in (
948
951
ei .exconly ()
952
+ )
949
953
950
954
@pytest .mark .skipif (IS_WINDOWS_PLATFORM , reason = 'No symlinks on Windows' )
951
955
def test_tar_with_file_symlinks (self ):
@@ -995,6 +999,18 @@ def test_tar_socket_file(self):
995
999
tar_data = tarfile .open (fileobj = archive )
996
1000
assert sorted (tar_data .getnames ()) == ['bar' , 'foo' ]
997
1001
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
+
998
1014
999
1015
class ShouldCheckDirectoryTest (unittest .TestCase ):
1000
1016
exclude_patterns = [
0 commit comments