Skip to content

Some errors are not caught by test_os.LoginTests.test_getlogin #139935

@yihong0618

Description

@yihong0618

Bug report

Bug description:

[hyi@rocky cpython]$ ./python -m unittest test.test_os.test_os.LoginTests.test_getlogin -v

test_getlogin (test.test_os.test_os.LoginTests.test_getlogin) ... ERROR

======================================================================
ERROR: test_getlogin (test.test_os.test_os.LoginTests.test_getlogin)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/hyi/cpython/Lib/test/test_os/test_os.py", line 3204, in test_getlogin
    user_name = os.getlogin()
FileNotFoundError: [Errno 2] No such file or directory

----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (errors=1)

This test bring back in patch #139498

but in some system there will be a FileNotFoundError
since FileNotFoundError is a subclass of OSError
but the errno maybe ENOENT in some linux

cc @vstinner

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15new features, bugs and security fixesOS-linuxtestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions