Skip to content

test_pathlib - test_group_no_follow_symlinks resolves group name from uid rather than gid #132356

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

Closed
befeleme opened this issue Apr 10, 2025 · 1 comment
Labels
tests Tests in the Lib/test dir topic-pathlib type-bug An unexpected behavior, bug, or error

Comments

@befeleme
Copy link
Contributor

befeleme commented Apr 10, 2025

Bug report

Bug description:

In Fedora 43 test_group_no_follow_symlinks started failing with a peculiar failure for Python 3.14 and Python 3.13:

======================================================================
FAIL: test_group_no_follow_symlinks (test.test_pathlib.test_pathlib.PathSubclassTest.test_group_no_follow_symlinks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.14/test/test_pathlib/test_pathlib.py", line 2071, in test_group_no_follow_symlinks
    self.assertEqual(expected_name, link.group(follow_symlinks=False))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'adm' != 'sys'
- adm
+ sys


======================================================================
FAIL: test_group_no_follow_symlinks (test.test_pathlib.test_pathlib.PathTest.test_group_no_follow_symlinks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.14/test/test_pathlib/test_pathlib.py", line 2071, in test_group_no_follow_symlinks
    self.assertEqual(expected_name, link.group(follow_symlinks=False))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'adm' != 'sys'
- adm
+ sys


======================================================================
FAIL: test_group_no_follow_symlinks (test.test_pathlib.test_pathlib.PosixPathTest.test_group_no_follow_symlinks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.14/test/test_pathlib/test_pathlib.py", line 2071, in test_group_no_follow_symlinks
    self.assertEqual(expected_name, link.group(follow_symlinks=False))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'adm' != 'sys'
- adm
+ sys

The gid, which is asserted the line above, is in both cases the same (3), but the names don't match.
The tests calls _get_pw_name_or_skip_test, which calls pwd.getpwuid(uid).pw_name - which in return stopped giving the right result in our environment.

expected_name = self._get_pw_name_or_skip_test(expected_gid)

The cut contents of the two system files (you can check it for yourself spawning the fedora:rawhide container with podman run -rm -it fedora:rawhide /usr/bin/bash):

bash-5.2# head /etc/group 
root:x:0:
sys:x:3:
adm:x:4:

bash-5.2# head /etc/passwd 
root:x:0:0:Super User:/root:/bin/bash
bin:x:1:1:bin:/bin:/usr/bin/nologin
daemon:x:2:2:daemon:/sbin:/usr/bin/nologin
adm:x:3:4:adm:/var/adm:/usr/bin/nologin

I believe the test should use the other helper function prepared _get_gr_name_or_skip_test. It was probably an accidental copy-paste omission in the first place. I verified this will make the tests pass.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

@befeleme befeleme added the type-bug An unexpected behavior, bug, or error label Apr 10, 2025
@picnixz picnixz added tests Tests in the Lib/test dir topic-pathlib labels Apr 11, 2025
barneygale pushed a commit that referenced this issue Apr 11, 2025
…ks (#132357)

Find the correct group name in test_group_no_follow_symlinks
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 11, 2025
…symlinks (pythonGH-132357)

Find the correct group name in test_group_no_follow_symlinks
(cherry picked from commit 3e1a47b)

Co-authored-by: Karolina Surma <[email protected]>
barneygale pushed a commit that referenced this issue Apr 11, 2025
…_symlinks (GH-132357) (#132404)

gh-132356: Find the correct group name in test_group_no_follow_symlinks (GH-132357)

Find the correct group name in test_group_no_follow_symlinks
(cherry picked from commit 3e1a47b)

Co-authored-by: Karolina Surma <[email protected]>
@barneygale
Copy link
Contributor

Thank you for reporting and fixing this!

befeleme added a commit to fedora-python/cpython that referenced this issue Apr 14, 2025
hrnciar pushed a commit to fedora-python/cpython that referenced this issue Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-pathlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants