Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Replace os.getlogin by getpass.getuser
The test `test_run_cwd_in_combination_with_runas` fails in some test environments (like Debian autopkgtest): ``` ====================================================================== ERROR: test_run_cwd_in_combination_with_runas (unit.modules.test_cmdmod.CMDMODTestCase) [CPU:0.0%|MEM:6.5%] cmd.run executes command in the cwd directory ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/unit/modules/test_cmdmod.py", line 449, in test_run_cwd_in_combination_with_runas runas = os.getlogin() OSError: [Errno 6] No such device or address ---------------------------------------------------------------------- ``` Therefore replace `os.getlogin` by `getpass.getuser` as recommended by upstream: "For most purposes, it is more useful to use `getpass.getuser()` since the latter checks the environment variables `LOGNAME` or `USERNAME` to find out who the user is, and falls back to `pwd.getpwuid(os.getuid())[0]` to get the login name of the current real user id." Bug-Debian: https://bugs.debian.org/964270 Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
- Loading branch information