1+ import pytest
12import subprocess
23import sys
34
@@ -36,23 +37,19 @@ def test_grab_x11(self):
3637 @unittest .skipIf (Image .core .HAVE_XCB , "tests missing XCB" )
3738 def test_grab_no_xcb (self ):
3839 if sys .platform not in ("win32" , "darwin" ):
39- with self . assertRaises (IOError ) as e :
40+ with pytest . raises (IOError ) as e :
4041 ImageGrab .grab ()
41- self .assertTrue (
42- str (e .exception ).startswith ("Pillow was built without XCB support" )
43- )
42+ assert str (e .value ).startswith ("Pillow was built without XCB support" )
4443
45- with self . assertRaises (IOError ) as e :
44+ with pytest . raises (IOError ) as e :
4645 ImageGrab .grab (xdisplay = "" )
47- self .assertTrue (
48- str (e .exception ).startswith ("Pillow was built without XCB support" )
49- )
46+ assert str (e .value ).startswith ("Pillow was built without XCB support" )
5047
5148 @unittest .skipUnless (Image .core .HAVE_XCB , "requires XCB" )
5249 def test_grab_invalid_xdisplay (self ):
53- with self . assertRaises (IOError ) as e :
50+ with pytest . raises (IOError ) as e :
5451 ImageGrab .grab (xdisplay = "error.test:0.0" )
55- assert str (e .exception ).startswith ("X connection failed" )
52+ assert str (e .value ).startswith ("X connection failed" )
5653
5754 def test_grabclipboard (self ):
5855 if sys .platform == "darwin" :
@@ -67,11 +64,9 @@ def test_grabclipboard(self):
6764 )
6865 p .communicate ()
6966 else :
70- with self . assertRaises (NotImplementedError ) as e :
67+ with pytest . raises (NotImplementedError ) as e :
7168 ImageGrab .grabclipboard ()
72- self .assertEqual (
73- str (e .exception ), "ImageGrab.grabclipboard() is macOS and Windows only"
74- )
69+ assert str (e .value ) == "ImageGrab.grabclipboard() is macOS and Windows only"
7570 return
7671
7772 im = ImageGrab .grabclipboard ()
0 commit comments