mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 20:27:06 +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.
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
from .helper import PillowTestCase, hopper, imagemagick_available
|
|
|
|
import os.path
|
|
|
|
|
|
class TestFilePalm(PillowTestCase):
|
|
_roundtrip = imagemagick_available()
|
|
|
|
def helper_save_as_palm(self, mode):
|
|
# Arrange
|
|
im = hopper(mode)
|
|
outfile = self.tempfile("temp_" + mode + ".palm")
|
|
|
|
# Act
|
|
im.save(outfile)
|
|
|
|
# Assert
|
|
self.assertTrue(os.path.isfile(outfile))
|
|
self.assertGreater(os.path.getsize(outfile), 0)
|
|
|
|
def roundtrip(self, mode):
|
|
if not self._roundtrip:
|
|
return
|
|
|
|
im = hopper(mode)
|
|
outfile = self.tempfile("temp.palm")
|
|
|
|
im.save(outfile)
|
|
converted = self.open_withImagemagick(outfile)
|
|
self.assert_image_equal(converted, im)
|
|
|
|
def test_monochrome(self):
|
|
# Arrange
|
|
mode = "1"
|
|
|
|
# Act / Assert
|
|
self.helper_save_as_palm(mode)
|
|
self.roundtrip(mode)
|
|
|
|
def test_p_mode(self):
|
|
# Arrange
|
|
mode = "P"
|
|
|
|
# Act / Assert
|
|
self.helper_save_as_palm(mode)
|
|
self.skipKnownBadTest("Palm P image is wrong")
|
|
self.roundtrip(mode)
|
|
|
|
def test_rgb_ioerror(self):
|
|
# Arrange
|
|
mode = "RGB"
|
|
|
|
# Act / Assert
|
|
self.assertRaises(IOError, self.helper_save_as_palm, mode)
|