]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90473: Fix more tests on platforms without umask (GH-95164)
authorChristian Heimes <christian@python.org>
Sat, 23 Jul 2022 10:26:31 +0000 (12:26 +0200)
committerGitHub <noreply@github.com>
Sat, 23 Jul 2022 10:26:31 +0000 (12:26 +0200)
Lib/distutils/tests/test_dir_util.py
Lib/test/support/os_helper.py
Lib/test/test_os.py

index f3ba0ee33b4bc11f61d7955c72bba979911f3449..ebd89f320dca89381176c82995b5057c5c86c178 100644 (file)
@@ -11,7 +11,7 @@ from distutils.dir_util import (mkpath, remove_tree, create_tree, copy_tree,
 
 from distutils import log
 from distutils.tests import support
-from test.support import run_unittest, is_emscripten
+from test.support import run_unittest, is_emscripten, is_wasi
 
 
 class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
@@ -55,7 +55,10 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
 
     @unittest.skipIf(sys.platform.startswith('win'),
         "This test is only appropriate for POSIX-like systems.")
-    @unittest.skipIf(is_emscripten, "Emscripten's umask is a stub.")
+    @unittest.skipIf(
+        is_emscripten or is_wasi,
+        "Emscripten's/WASI's umask is a stub."
+    )
     def test_mkpath_with_custom_mode(self):
         # Get and set the current umask value for testing mode bits.
         umask = os.umask(0o002)
index 61d12f59e4a6024aa9ad8c6d65d444c6077d8f2f..f37a442aa0e6c8e64bdd4d06e42c6c5fd4db2c9f 100644 (file)
@@ -658,6 +658,11 @@ if hasattr(os, "umask"):
             yield
         finally:
             os.umask(oldmask)
+else:
+    @contextlib.contextmanager
+    def temp_umask(umask):
+        """no-op on platforms without umask()"""
+        yield
 
 
 class EnvironmentVarGuard(collections.abc.MutableMapping):
index 29f69a8f475b206fc097b7daf9e7cb36b941aff6..9970b234b4831b6a83ceb21a6408a9d5bcc7ef05 100644 (file)
@@ -1607,6 +1607,10 @@ class MakedirTests(unittest.TestCase):
                 self.assertEqual(os.stat(path).st_mode & 0o777, 0o555)
                 self.assertEqual(os.stat(parent).st_mode & 0o777, 0o775)
 
+    @unittest.skipIf(
+        support.is_emscripten or support.is_wasi,
+        "Emscripten's/WASI's umask is a stub."
+    )
     def test_exist_ok_existing_directory(self):
         path = os.path.join(os_helper.TESTFN, 'dir1')
         mode = 0o777
@@ -1621,6 +1625,10 @@ class MakedirTests(unittest.TestCase):
         # Issue #25583: A drive root could raise PermissionError on Windows
         os.makedirs(os.path.abspath('/'), exist_ok=True)
 
+    @unittest.skipIf(
+        support.is_emscripten or support.is_wasi,
+        "Emscripten's/WASI's umask is a stub."
+    )
     def test_exist_ok_s_isgid_directory(self):
         path = os.path.join(os_helper.TESTFN, 'dir1')
         S_ISGID = stat.S_ISGID