summaryrefslogtreecommitdiff
path: root/Lib/test/test_zipfile.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2008-07-25 19:42:26 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2008-07-25 19:42:26 +0000
commit5fdfa3e36d08e8627cd57d2f9653e1ec634f8355 (patch)
treeff25b4e170ef2805c97c129fed0aa681e6fcea23 /Lib/test/test_zipfile.py
parent8c664e8628ace6a9f3b64980af262b67cd7f3e59 (diff)
downloadcpython-git-5fdfa3e36d08e8627cd57d2f9653e1ec634f8355.tar.gz
#3394: zipfile.writestr doesn't set external attributes, so files are extracted mode 000 on Unix
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 90ac4f6f6e..5e993821ab 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -372,6 +372,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, 0600 << 16)
+
+ def test_writestr_permissions(self):
+ for f in (TESTFN2, TemporaryFile(), StringIO()):
+ self.zip_test_writestr_permissions(f, zipfile.ZIP_STORED)
+
def tearDown(self):
os.remove(TESTFN)
os.remove(TESTFN2)