Use pytest.raises match argument

This commit is contained in:
Andrew Murray 2022-12-29 10:27:03 +11:00
parent 2ecf88eaa6
commit 73a2c3049f

View File

@ -65,12 +65,12 @@ $bmp = New-Object Drawing.Bitmap 200, 200
p.communicate()
else:
if not shutil.which("wl-paste"):
with pytest.raises(NotImplementedError) as e:
with pytest.raises(
NotImplementedError,
match="wl-paste or xclip is required for"
r" ImageGrab.grabclipboard\(\) on Linux",
):
ImageGrab.grabclipboard()
assert (
str(e.value) == "wl-paste or xclip is required"
" for ImageGrab.grabclipboard() on Linux"
)
return
ImageGrab.grabclipboard()