Skip to content

Commit 6839324

Browse files
authored
gh-90473: Fix more tests on platforms without umask (GH-95164)
1 parent 41a5b84 commit 6839324

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Lib/distutils/tests/test_dir_util.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from distutils import log
1313
from distutils.tests import support
14-
from test.support import run_unittest, is_emscripten
14+
from test.support import run_unittest, is_emscripten, is_wasi
1515

1616

1717
class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
@@ -55,7 +55,10 @@ def test_mkpath_remove_tree_verbosity(self):
5555

5656
@unittest.skipIf(sys.platform.startswith('win'),
5757
"This test is only appropriate for POSIX-like systems.")
58-
@unittest.skipIf(is_emscripten, "Emscripten's umask is a stub.")
58+
@unittest.skipIf(
59+
is_emscripten or is_wasi,
60+
"Emscripten's/WASI's umask is a stub."
61+
)
5962
def test_mkpath_with_custom_mode(self):
6063
# Get and set the current umask value for testing mode bits.
6164
umask = os.umask(0o002)

Lib/test/support/os_helper.py

+5
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,11 @@ def temp_umask(umask):
658658
yield
659659
finally:
660660
os.umask(oldmask)
661+
else:
662+
@contextlib.contextmanager
663+
def temp_umask(umask):
664+
"""no-op on platforms without umask()"""
665+
yield
661666

662667

663668
class EnvironmentVarGuard(collections.abc.MutableMapping):

Lib/test/test_os.py

+8
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,10 @@ def test_mode(self):
16071607
self.assertEqual(os.stat(path).st_mode & 0o777, 0o555)
16081608
self.assertEqual(os.stat(parent).st_mode & 0o777, 0o775)
16091609

1610+
@unittest.skipIf(
1611+
support.is_emscripten or support.is_wasi,
1612+
"Emscripten's/WASI's umask is a stub."
1613+
)
16101614
def test_exist_ok_existing_directory(self):
16111615
path = os.path.join(os_helper.TESTFN, 'dir1')
16121616
mode = 0o777
@@ -1621,6 +1625,10 @@ def test_exist_ok_existing_directory(self):
16211625
# Issue #25583: A drive root could raise PermissionError on Windows
16221626
os.makedirs(os.path.abspath('/'), exist_ok=True)
16231627

1628+
@unittest.skipIf(
1629+
support.is_emscripten or support.is_wasi,
1630+
"Emscripten's/WASI's umask is a stub."
1631+
)
16241632
def test_exist_ok_s_isgid_directory(self):
16251633
path = os.path.join(os_helper.TESTFN, 'dir1')
16261634
S_ISGID = stat.S_ISGID

0 commit comments

Comments
 (0)