Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.11] gh-90473: Fix more tests on platforms without umask (GH-95164) #95167

Merged
merged 1 commit into from
Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/distutils/tests/test_dir_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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):
Expand Down Expand Up @@ -55,7 +55,10 @@ def test_mkpath_remove_tree_verbosity(self):

@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)
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/support/os_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ def temp_umask(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):
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,10 @@ def test_mode(self):
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
Expand All @@ -1621,6 +1625,10 @@ def test_exist_ok_existing_directory(self):
# 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
Expand Down