Added test

This commit is contained in:
Andrew Murray 2024-01-28 16:53:27 +11:00
parent 39cbd4f0f1
commit 5efa2ade22
2 changed files with 17 additions and 1 deletions

View File

@ -119,3 +119,15 @@ $ms = new-object System.IO.MemoryStream(, $bytes)
subprocess.call(["wl-copy"], stdin=fp)
im = ImageGrab.grabclipboard()
assert_image_equal_tofile(im, image_path)
@pytest.mark.skipif(
(
sys.platform != "linux"
or not all(shutil.which(cmd) for cmd in ("wl-paste", "wl-copy"))
),
reason="Linux with wl-clipboard only",
)
@pytest.mark.parametrize("arg", ("text", "--clear"))
def test_grabclipboard_wl_clipboard_errors(self, arg):
subprocess.call(["wl-copy", arg])
assert ImageGrab.grabclipboard() is None

View File

@ -162,7 +162,11 @@ def grabclipboard():
for silent_error in [
# wl-paste, when the clipboard is empty
b"Nothing is copied",
# wl-paste/debian xclip, when an image isn't available
# Ubuntu/Debian wl-paste, when the clipboard is empty
b"No selection",
# Ubuntu/Debian wl-paste, when an image isn't available
b"No suitable type of content copied",
# wl-paste or Ubuntu/Debian xclip, when an image isn't available
b" not available",
# xclip, when an image isn't available
b"cannot convert ",