summaryrefslogtreecommitdiff
path: root/Lib/test/test_zipfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_zipfile.py')
-rw-r--r--Lib/test/test_zipfile.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index a647fc6e2c..9e565fb153 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -365,6 +365,19 @@ class TestsWithSourceFile(unittest.TestCase):
# remove the test file subdirectories
shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir'))
+ def zip_test_writestr_permissions(self, f, compression):
+ # Make sure that writestr creates files with mode 0600,
+ # when it is passed a name rather than a ZipInfo instance.
+
+ self.makeTestArchive(f, compression)
+ zipfp = zipfile.ZipFile(f, "r")
+ zinfo = zipfp.getinfo('strfile')
+ self.assertEqual(zinfo.external_attr, 0o600 << 16)
+
+ def test_writestr_permissions(self):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+ self.zip_test_writestr_permissions(f, zipfile.ZIP_STORED)
+
def tearDown(self):
os.remove(TESTFN)
os.remove(TESTFN2)