forked from python-pillow/Pillow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_imagegrab.py
49 lines (36 loc) · 1.26 KB
/
test_imagegrab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from helper import unittest, PillowTestCase, on_appveyor
import sys
try:
from PIL import ImageGrab
class TestImageGrab(PillowTestCase):
@unittest.skipIf(on_appveyor(), "Test fails on appveyor")
def test_grab(self):
im = ImageGrab.grab()
self.assert_image(im, im.mode, im.size)
@unittest.skipIf(on_appveyor(), "Test fails on appveyor")
def test_grab2(self):
im = ImageGrab.grab()
self.assert_image(im, im.mode, im.size)
except ImportError:
class TestImageGrab(PillowTestCase):
def test_skip(self):
self.skipTest("ImportError")
class TestImageGrabImport(PillowTestCase):
def test_import(self):
# Arrange
exception = None
# Act
try:
from PIL import ImageGrab
ImageGrab.__name__ # dummy to prevent Pyflakes warning
except Exception as e:
exception = e
# Assert
if sys.platform in ["win32", "darwin"]:
self.assertIsNone(exception)
else:
self.assertIsInstance(exception, ImportError)
self.assertEqual(str(exception),
"ImageGrab is macOS and Windows only")
if __name__ == '__main__':
unittest.main()