diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index 01442dc69f0..2139955ff7a 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -65,12 +65,12 @@ def test_grabclipboard(self): 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" + " ImageGrab.grabclipboard\(\) on Linux", + ): ImageGrab.grabclipboard() - assert ( - str(e.value) == "wl-paste or xclip is required" - " for ImageGrab.grabclipboard() on Linux" - ) return ImageGrab.grabclipboard()