Pillow/Tests/test_file_xvthumb.py
Jon Dufresne 4de5477b61 Remove unnecessary unittest.main() boilerplate from test files
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.
2019-02-03 10:10:16 -08:00

37 lines
1001 B
Python

from .helper import hopper, PillowTestCase
from PIL import Image, XVThumbImagePlugin
TEST_FILE = "Tests/images/hopper.p7"
class TestFileXVThumb(PillowTestCase):
def test_open(self):
# Act
im = Image.open(TEST_FILE)
# Assert
self.assertEqual(im.format, "XVThumb")
# Create a Hopper image with a similar XV palette
im_hopper = hopper().quantize(palette=im)
self.assert_image_similar(im, im_hopper, 9)
def test_unexpected_eof(self):
# Test unexpected EOF reading XV thumbnail file
# Arrange
bad_file = "Tests/images/hopper_bad.p7"
# Act / Assert
self.assertRaises(SyntaxError,
XVThumbImagePlugin.XVThumbImageFile, bad_file)
def test_invalid_file(self):
# Arrange
invalid_file = "Tests/images/flower.jpg"
# Act / Assert
self.assertRaises(SyntaxError,
XVThumbImagePlugin.XVThumbImageFile, invalid_file)