From 0f0064c2d7d482f3cba2620d673862b142a4e7f5 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 30 Oct 2026 21:44:40 +0100 Subject: [PATCH] test: the fake host never answers with this machine's uid CI runs as root, which the owner step skips, so three owner tests failed there while they passed for a normal user. --- tests/test_sudo_history.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 )