This amends
4e7e2dd043c1da85b0c157d3ed24866b77e83a4f to catch errors
that `os.getlogin` can raise as specified by POSIX and Linux/glibc [1].
[1]: https://man7.org/linux/man-pages/man3/getlogin.3.html#ERRORS
---------
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
try:
user_name = os.getlogin()
except OSError as exc:
- if exc.errno in (errno.ENOTTY, errno.ENXIO):
+ # See https://man7.org/linux/man-pages/man3/getlogin.3.html#ERRORS.
+ allowed_errors = (
+ # defined by POSIX
+ errno.EMFILE, errno.ENFILE, errno.ENXIO, errno.ERANGE,
+ # defined by Linux/glibc
+ errno.ENOENT, errno.ENOMEM, errno.ENOTTY,
+ )
+ if exc.errno in allowed_errors:
self.skipTest(str(exc))
else:
raise