mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
4de5477b61
With the introduction and use of pytest, it is simple and easy to execute specific tests in isolation through documented command line arguments. Either by specifying the module path or through the `-k EXPRESSION` argument. There is no longer any need to provide the boilerplate: if __name__ == '__main__': unittest.main() To every test file. It is simply noise. The pattern remains in test files that aren't named with `test_*` as those files are not discovered and executed by pytest by default.
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from .helper import PillowTestCase, hopper
|
|
|
|
from PIL import Image
|
|
from PIL import ImageShow
|
|
|
|
|
|
class TestImageShow(PillowTestCase):
|
|
|
|
def test_sanity(self):
|
|
dir(Image)
|
|
dir(ImageShow)
|
|
|
|
def test_register(self):
|
|
# Test registering a viewer that is not a class
|
|
ImageShow.register("not a class")
|
|
|
|
# Restore original state
|
|
ImageShow._viewers.pop()
|
|
|
|
def test_show(self):
|
|
class TestViewer:
|
|
methodCalled = False
|
|
|
|
def show(self, image, title=None, **options):
|
|
self.methodCalled = True
|
|
return True
|
|
viewer = TestViewer()
|
|
ImageShow.register(viewer, -1)
|
|
|
|
im = hopper()
|
|
self.assertTrue(ImageShow.show(im))
|
|
self.assertTrue(viewer.methodCalled)
|
|
|
|
# Restore original state
|
|
ImageShow._viewers.pop(0)
|
|
|
|
def test_viewer(self):
|
|
viewer = ImageShow.Viewer()
|
|
|
|
self.assertIsNone(viewer.get_format(None))
|
|
|
|
self.assertRaises(NotImplementedError, viewer.get_command, None)
|
|
|
|
def test_viewers(self):
|
|
for viewer in ImageShow._viewers:
|
|
viewer.get_command('test.jpg')
|