diff --git a/tests/test_sudo_history.py b/tests/test_sudo_history.py index d7415c0..76d62e6 100644 --- a/tests/test_sudo_history.py +++ b/tests/test_sudo_history.py @@ -33,7 +33,7 @@ class _Host(SudoHistoryMixin): self.home = home self.bin_dir = bin_dir self.root = root - #: Who ``id -un`` says the login user is; None for this machine's answer. + #: Who ``id -un`` says the login user is; None for this machine's user name. self.user: str | None = None self.ran: list[tuple[str, bool]] = [] @@ -55,8 +55,9 @@ class _Host(SudoHistoryMixin): } if command.strip() == "id -u; id -un" and self.root: return CommandResult("0\nroot\n", "", 0) - if command.strip() == "id -u; id -un" and self.user: - return CommandResult(f"4242\n{self.user}\n", "", 0) + if command.strip() == "id -u; id -un": + # Never this machine's uid: CI runs as root, which the owner step skips. + return CommandResult(f"4242\n{self.user or getpass.getuser()}\n", "", 0) done = subprocess.run( # noqa: S603 - the test's own scripts ["sh", "-c", command], capture_output=True, text=True, env=env, timeout=timeout )