From 8e64e5eef0173b3f7586404650151acc684e57d7 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 24 Jul 2026 12:32:00 +0200 Subject: Use XWayland clipboard bridge for reliable copying --- tests/test_desktop.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_desktop.py (limited to 'tests') diff --git a/tests/test_desktop.py b/tests/test_desktop.py new file mode 100644 index 0000000..a273617 --- /dev/null +++ b/tests/test_desktop.py @@ -0,0 +1,33 @@ +import subprocess +import unittest +from unittest.mock import MagicMock, patch + +from parley.desktop import DesktopIntegrationError, copy_text + + +class ClipboardTests(unittest.TestCase): + @patch("parley.desktop.subprocess.run") + @patch("parley.desktop.shutil.which", return_value="/usr/bin/xclip") + def test_copies_utf8_text(self, which: MagicMock, run: MagicMock) -> None: + run.return_value.returncode = 0 + run.return_value.stderr = "" + + copy_text("héllo") + + run.assert_called_once_with( + ["/usr/bin/xclip", "-selection", "clipboard", "-in"], + input="héllo", + text=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + timeout=10, + ) + + @patch("parley.desktop.shutil.which", return_value=None) + def test_reports_missing_xclip(self, which: MagicMock) -> None: + with self.assertRaisesRegex(DesktopIntegrationError, "xclip is not installed"): + copy_text("text") + + +if __name__ == "__main__": + unittest.main() -- cgit v1.3.1