8000 gh-103363: Add follow_symlinks argument to `pathlib.Path.owner()` and `group()` by kamilturek · Pull Request #107962 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-103363: Add follow_symlinks argument to pathlib.Path.owner() and group() #107962

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

Merged
merged 10 commits into from
Dec 4, 2023
Prev Previous commit
Next Next commit
Move all_users and all_groups into tests
  • Loading branch information
kamilturek committed Dec 2, 2023
commit 9077bc302164217a756afabd4d25c61d6fabd296
24 changes: 8 additions & 16 deletions Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ def test_is_notimplemented(self):
self.assertTrue(isinstance(pathlib.UnsupportedOperation(), NotImplementedError))


try:
import pwd
all_users = [u.pw_uid for u in pwd.getpwall()]
except (ImportError, AttributeError):
all_users = []


try:
import grp
all_groups = [g.gr_gid for g in grp.getgrall()]
except (ImportError, AttributeError):
all_groups = []


# Make sure any symbolic links in the base test path are resolved.
BASE = os.path.realpath(TESTFN)
join = lambda *x: os.path.join(BASE, *x)
Expand Down Expand Up @@ -2601,8 +2587,11 @@ def test_owner(self):

@unittest.skipUnless(pwd, "the pwd module is needed for this test")
@unittest.skipUnless(root_in_posix, "test needs root privilege")
@unittest.skipUnless(len(all_users) > 1, "test needs more than one user")
def test_owner_no_follow_symlinks(self):
all_users = [u.pw_uid for u in pwd.getpwall()]
if len(all_users) < 2:
self.skipTest("test needs more than one user")

target = self.cls(BASE) / 'fileA'
link = self.cls(BASE) / 'linkA'

Expand Down Expand Up @@ -2633,8 +2622,11 @@ def test_group(self):

@unittest.skipUnless(grp, "the grp module is needed for this test")
@unittest.skipUnless(root_in_posix, "test needs root privilege")
@unittest.skipUnless(len(all_groups) > 1, "test needs more than one group")
def test_group_no_follow_symlinks(self):
all_groups = [g.gr_gid for g in grp.getgrall()]
if len(all_groups) < 2:
self.skipTest("test needs more than one group")

target = self.cls(BASE) / 'fileA'
link = self.cls(BASE) / 'linkA'

Expand Down
0