]> granicus.if.org Git - python/commitdiff
Issue #17753: Skip test_zipfile tests which require write access to test
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 14 Feb 2015 21:17:13 +0000 (23:17 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 14 Feb 2015 21:17:13 +0000 (23:17 +0200)
and email.test.

Lib/test/test_zipfile.py

index f567c78ad8ec8bda735c967a4c4db4444a933ce4..71c6605829cb5ba17d8902de0be9d403a6420324 100644 (file)
@@ -775,7 +775,12 @@ class TestZip64InSmallFiles(unittest.TestCase):
 
 
 class PyZipFileTests(unittest.TestCase):
+    def requiresWriteAccess(self, path):
+        if not os.access(path, os.W_OK):
+            self.skipTest('requires write access to the installed location')
+
     def test_write_pyfile(self):
+        self.requiresWriteAccess(os.path.dirname(__file__))
         with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
             fn = __file__
             if fn.endswith('.pyc') or fn.endswith('.pyo'):
@@ -803,6 +808,7 @@ class PyZipFileTests(unittest.TestCase):
     def test_write_python_package(self):
         import email
         packagedir = os.path.dirname(email.__file__)
+        self.requiresWriteAccess(packagedir)
 
         with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
             zipfp.writepy(packagedir)