diff options
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r-- | Lib/test/test_tarfile.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index ff04ef8..43527ef 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -846,6 +846,24 @@ class StreamWriteTest(WriteTestBase): self.assertTrue(data.count(b"\0") == tarfile.RECORDSIZE, "incorrect zero padding") + def test_file_mode(self): + # Test for issue #8464: Create files with correct + # permissions. + if sys.platform == "win32" or not hasattr(os, "umask"): + return + + if os.path.exists(tmpname): + os.remove(tmpname) + + original_umask = os.umask(0o022) + try: + tar = tarfile.open(tmpname, self.mode) + tar.close() + mode = os.stat(tmpname).st_mode & 0o777 + self.assertEqual(mode, 0o644, "wrong file permissions") + finally: + os.umask(original_umask) + class GNUWriteTest(unittest.TestCase): # This testcase checks for correct creation of GNU Longname |