Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Mar 11, 2020
1 parent 25eb542 commit c48bc1b
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions Tests/test_imagegrab.py
@@ -1,3 +1,4 @@
import pytest
import subprocess
import sys

Expand Down Expand Up @@ -36,23 +37,19 @@ def test_grab_x11(self):
@unittest.skipIf(Image.core.HAVE_XCB, "tests missing XCB")
def test_grab_no_xcb(self):
if sys.platform not in ("win32", "darwin"):
with self.assertRaises(IOError) as e:
with pytest.raises(IOError) as e:
ImageGrab.grab()
self.assertTrue(
str(e.exception).startswith("Pillow was built without XCB support")
)
assert str(e.value).startswith("Pillow was built without XCB support")

with self.assertRaises(IOError) as e:
with pytest.raises(IOError) as e:
ImageGrab.grab(xdisplay="")
self.assertTrue(
str(e.exception).startswith("Pillow was built without XCB support")
)
assert str(e.value).startswith("Pillow was built without XCB support")

@unittest.skipUnless(Image.core.HAVE_XCB, "requires XCB")
def test_grab_invalid_xdisplay(self):
with self.assertRaises(IOError) as e:
with pytest.raises(IOError) as e:
ImageGrab.grab(xdisplay="error.test:0.0")
assert str(e.exception).startswith("X connection failed")
assert str(e.value).startswith("X connection failed")

def test_grabclipboard(self):
if sys.platform == "darwin":
Expand All @@ -67,11 +64,9 @@ def test_grabclipboard(self):
)
p.communicate()
else:
with self.assertRaises(NotImplementedError) as e:
with pytest.raises(NotImplementedError) as e:
ImageGrab.grabclipboard()
self.assertEqual(
str(e.exception), "ImageGrab.grabclipboard() is macOS and Windows only"
)
assert str(e.value) == "ImageGrab.grabclipboard() is macOS and Windows only"
return

im = ImageGrab.grabclipboard()
Expand Down

0 comments on commit c48bc1b

Please sign in to comment.