diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-08-13 17:39:14 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-13 17:39:14 (GMT) |
| commit | d218810e203bc8a4f40818ebd51d2be90d3966cd (patch) | |
| tree | 2d9632d7747a03970e5fadc2e9bb01add20f3d67 /Lib/test/test_pathlib/test_pathlib.py | |
| parent | 4aa0e795a98325619832fbafda9ee55f46f985e3 (diff) | |
| download | cpython-d218810e203bc8a4f40818ebd51d2be90d3966cd.zip cpython-d218810e203bc8a4f40818ebd51d2be90d3966cd.tar.gz cpython-d218810e203bc8a4f40818ebd51d2be90d3966cd.tar.bz2 | |
[3.13] GH-85633: Fix pathlib test failures on filesystems without world-write. (GH-122883) (#122979)
GH-85633: Fix pathlib test failures on filesystems without world-write. (GH-122883)
Replace `umask(0)` with `umask(0o002)` so the created files are not
world-writable, and replace `umask(0o022)` with `umask(0o026)` to check
that permissions for 'others' can still be set.
(cherry picked from commit 5f6851152254b4b9d70af4ae5aea3f20965cee28)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib.py')
| -rw-r--r-- | Lib/test/test_pathlib/test_pathlib.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 5fd1a41..ff054e7 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -1296,18 +1296,20 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): ) @needs_posix def test_open_mode(self): - old_mask = os.umask(0) + # Unmask all permissions except world-write, which may + # not be supported on some filesystems (see GH-85633.) + old_mask = os.umask(0o002) self.addCleanup(os.umask, old_mask) p = self.cls(self.base) with (p / 'new_file').open('wb'): pass st = os.stat(self.parser.join(self.base, 'new_file')) - self.assertEqual(stat.S_IMODE(st.st_mode), 0o666) - os.umask(0o022) + self.assertEqual(stat.S_IMODE(st.st_mode), 0o664) + os.umask(0o026) with (p / 'other_new_file').open('wb'): pass st = os.stat(self.parser.join(self.base, 'other_new_file')) - self.assertEqual(stat.S_IMODE(st.st_mode), 0o644) + self.assertEqual(stat.S_IMODE(st.st_mode), 0o640) @needs_posix def test_resolve_root(self): @@ -1325,16 +1327,18 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): ) @needs_posix def test_touch_mode(self): - old_mask = os.umask(0) + # Unmask all permissions except world-write, which may + # not be supported on some filesystems (see GH-85633.) + old_mask = os.umask(0o002) self.addCleanup(os.umask, old_mask) p = self.cls(self.base) (p / 'new_file').touch() st = os.stat(self.parser.join(self.base, 'new_file')) - self.assertEqual(stat.S_IMODE(st.st_mode), 0o666) - os.umask(0o022) + self.assertEqual(stat.S_IMODE(st.st_mode), 0o664) + os.umask(0o026) (p / 'other_new_file').touch() st = os.stat(self.parser.join(self.base, 'other_new_file')) - self.assertEqual(stat.S_IMODE(st.st_mode), 0o644) + self.assertEqual(stat.S_IMODE(st.st_mode), 0o640) (p / 'masked_new_file').touch(mode=0o750) st = os.stat(self.parser.join(self.base, 'masked_new_file')) self.assertEqual(stat.S_IMODE(st.st_mode), 0o750) |
