diff options
| author | Yuval Adam <_@yuv.al> | 2026-07-24 12:32:00 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2026-07-24 12:32:00 +0200 |
| commit | 8e64e5eef0173b3f7586404650151acc684e57d7 (patch) | |
| tree | e99ddec68a0b9f43ec685e5be7573cbd8c5dd35c /tests/test_desktop.py | |
| parent | 0747fd8318a092778d420eeee55851cf49ee8aec (diff) | |
Use XWayland clipboard bridge for reliable copying
Diffstat (limited to 'tests/test_desktop.py')
| -rw-r--r-- | tests/test_desktop.py | 33 |
1 files changed, 33 insertions, 0 deletions
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() |
