Skip to content

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

Closed
@befeleme

Description

@befeleme

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtopic-pathlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions