From db9839bd0019be3c009e9f48d48bad76099f4057 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sun, 22 Nov 2026 15:43:30 -0500 Subject: [PATCH] fix(desktop): expect the host abspath in the linux system-browser test _command() runs os.path.abspath on shutil.which("xdg-open"). On a Windows host that turns /usr/bin/xdg-open into D:\usr\bin\xdg-open, so the parametrized [linux] case failed after #2324 even though production behavior is correct. Assert against os.path.abspath of the injected path instead of a hardcoded POSIX string. The [win32] case is unchanged. --- packages/desktop/tests/test_engine/test_system_browser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/desktop/tests/test_engine/test_system_browser.py b/packages/desktop/tests/test_engine/test_system_browser.py index 6112868e55..0590036812 100644 --- a/packages/desktop/tests/test_engine/test_system_browser.py +++ b/packages/desktop/tests/test_engine/test_system_browser.py @@ -32,7 +32,8 @@ def test_default_handler_receives_one_literal_url(platform, monkeypatch): monkeypatch.setattr(sys, "platform", platform) monkeypatch.setenv("BROWSER", "sh -c unsafe-command %s") monkeypatch.setattr(os, "access", lambda *_: True) - monkeypatch.setattr(system_browser.shutil, "which", lambda _: "/usr/bin/xdg-open") + xdg_open = "/usr/bin/xdg-open" + monkeypatch.setattr(system_browser.shutil, "which", lambda _: xdg_open) calls = [] monkeypatch.setattr(os, "startfile", lambda *args: calls.append(args), raising=False) monkeypatch.setattr( @@ -44,7 +45,10 @@ def test_default_handler_receives_one_literal_url(platform, monkeypatch): if platform == "win32": assert calls == [(url,)] else: - command = ["/usr/bin/open", "--"] if platform == "darwin" else ["/usr/bin/xdg-open"] + # linux uses os.path.abspath(shutil.which("xdg-open")); abspath of a + # POSIX path is host-dependent (on Windows, /usr/bin/xdg-open becomes + # D:\usr\bin\xdg-open). Match that, rather than a hardcoded POSIX path. + command = ["/usr/bin/open", "--"] if platform == "darwin" else [os.path.abspath(xdg_open)] assert calls == [ ( ([*command, url],),