diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index 032dac8cc..35aaa7ff0 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -59,8 +59,10 @@ class TestImageGrab: @pytest.mark.skipif(sys.platform != "win32", reason="Windows only") def test_grab_invalid_handle(self) -> None: - with pytest.raises(OSError): + with pytest.raises(OSError, match="unable to get device context for handle"): ImageGrab.grab(window=-1) + with pytest.raises(OSError, match="screen grab failed"): + ImageGrab.grab(window=0) def test_grabclipboard(self) -> None: if sys.platform == "darwin":