diff options
author | Barney Gale <barney.gale@gmail.com> | 2021-04-07 16:53:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 16:53:39 +0100 |
commit | abf964942f97f6489360a75fd57b5e4f41c75f57 (patch) | |
tree | 109be2453227ad4cae6204d1f364704527dc3af6 /Lib/test/test_pathlib.py | |
parent | 7a7ba3d343d360a03a34bc3901628f9f40a58307 (diff) | |
download | cpython-git-abf964942f97f6489360a75fd57b5e4f41c75f57.tar.gz |
bpo-39906: Add follow_symlinks parameter to pathlib.Path.stat() and chmod() (GH-18864)
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 9be72941d3..2643119352 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1828,6 +1828,21 @@ class _BasePathTest(object): p.chmod(new_mode) self.assertEqual(p.stat().st_mode, new_mode) + # On Windows, os.chmod does not follow symlinks (issue #15411) + @only_posix + def test_chmod_follow_symlinks_true(self): + p = self.cls(BASE) / 'linkA' + q = p.resolve() + mode = q.stat().st_mode + # Clear writable bit. + new_mode = mode & ~0o222 + p.chmod(new_mode, follow_symlinks=True) + self.assertEqual(q.stat().st_mode, new_mode) + # Set writable bit + new_mode = mode | 0o222 + p.chmod(new_mode, follow_symlinks=True) + self.assertEqual(q.stat().st_mode, new_mode) + # XXX also need a test for lchmod. def test_stat(self): @@ -1840,6 +1855,17 @@ class _BasePathTest(object): self.assertNotEqual(p.stat(), st) @os_helper.skip_unless_symlink + def test_stat_no_follow_symlinks(self): + p = self.cls(BASE) / 'linkA' + st = p.stat() + self.assertNotEqual(st, p.stat(follow_symlinks=False)) + + def test_stat_no_follow_symlinks_nosymlink(self): + p = self.cls(BASE) / 'fileA' + st = p.stat() + self.assertEqual(st, p.stat(follow_symlinks=False)) + + @os_helper.skip_unless_symlink def test_lstat(self): p = self.cls(BASE)/ 'linkA' st = p.stat() |