Skip to content

The agent that grows with you

test(cli): cover macOS clipboard image file-url paste

xxxigm06ae26bf70e3
diff --git a/tests/tools/test_clipboard.py b/tests/tools/test_clipboard.py
index 6e08d7f9bb7..98ad11453f1 100644
--- a/tests/tools/test_clipboard.py
+++ b/tests/tools/test_clipboard.py
@@ -114,6 +114,43 @@ class TestMacosOsascript:
assert _macos_osascript(dest) is False
+class TestMacosClipboardFileUrl:
+ """Finder / file-copy puts «class furl» on the clipboard, not PNGf/TIFF.
+
+ Other apps still paste the image; Hermes must treat a local image file-url
+ as a clipboard image too.
+ """
+
+ def _furl_run(self, src: Path):
+ def fake_run(cmd, **kw):
+ joined = " ".join(str(part) for part in cmd)
+ if "clipboard info" in joined:
+ return MagicMock(stdout="«class furl», 28", returncode=0)
+ if "pngpaste" in joined:
+ return MagicMock(returncode=1, stdout=b"", stderr=b"")
+ if "«class PNGf»" in joined:
+ return MagicMock(stdout="fail", returncode=0)
+ if "«class furl»" in joined:
+ return MagicMock(stdout=f"{src}\n", returncode=0)
+ return MagicMock(stdout="", returncode=1)
+ return fake_run
+
+ def test_copied_image_file_is_a_clipboard_image(self, tmp_path):
+ src = tmp_path / "shot.png"
+ src.write_bytes(FAKE_PNG)
+ with patch("hermes_cli.clipboard.subprocess.run", side_effect=self._furl_run(src)):
+ assert _macos_has_image() is True
+
+ def test_copied_image_file_saves_as_png(self, tmp_path):
+ src = tmp_path / "shot.png"
+ src.write_bytes(FAKE_PNG)
+ dest = tmp_path / "out.png"
+ with patch("hermes_cli.clipboard.sys.platform", "darwin"), \
+ patch("hermes_cli.clipboard.subprocess.run", side_effect=self._furl_run(src)):
+ assert save_clipboard_image(dest) is True
+ assert dest.read_bytes().startswith(b"\x89PNG")
+
+
# ── WSL detection ────────────────────────────────────────────────────────
class TestIsWsl: