Skip to content

The agent that grows with you

test(bot-screen): NOPASSWD install fixture hands the drain a real pipe

teknium186e9edad003a
diff --git a/tests/tools/test_bot_desktop_install.py b/tests/tools/test_bot_desktop_install.py
index 40265aa7bc0..820f92d16cb 100644
--- a/tests/tools/test_bot_desktop_install.py
+++ b/tests/tools/test_bot_desktop_install.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import os
import threading
import pytest
@@ -109,14 +110,20 @@ def test_passwordless_sudo_runs_the_install_without_asking_for_a_password(monkey
spawned: list[list[str]] = []
class _Proc:
+ """Stands in for the sudo child: the drain reads the pipe by fd, so stdout is a real pipe with
+ the output already written and the write end closed (EOF)."""
pid = 4242
+ returncode = 0
stdin = __import__("io").StringIO()
def __init__(self, argv, **kw):
spawned.append(argv)
- self.stdout = iter(["Reading package lists...\n", "Done\n"])
+ r, w = os.pipe()
+ os.write(w, b"Reading package lists...\nDone\n")
+ os.close(w)
+ self.stdout = os.fdopen(r, "rb")
- def wait(self):
+ def wait(self, timeout=None):
return 0
monkeypatch.setattr(install.subprocess, "Popen", _Proc)