mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 02:16:19 +03:00
60 lines
1.1 KiB
Python
60 lines
1.1 KiB
Python
from helper import unittest, PillowTestCase, tearDownModule, lena
|
|
|
|
import os.path
|
|
|
|
|
|
class TestFilePdf(PillowTestCase):
|
|
|
|
def helper_save_as_pdf(self, mode):
|
|
# Arrange
|
|
im = lena(mode)
|
|
outfile = self.tempfile("temp_" + mode + ".pdf")
|
|
|
|
# Act
|
|
im.save(outfile)
|
|
|
|
# Assert
|
|
self.assertTrue(os.path.isfile(outfile))
|
|
self.assertGreater(os.path.getsize(outfile), 0)
|
|
|
|
def test_monochrome(self):
|
|
# Arrange
|
|
mode = "1"
|
|
|
|
# Act / Assert
|
|
self.helper_save_as_pdf(mode)
|
|
|
|
def test_greyscale(self):
|
|
# Arrange
|
|
mode = "L"
|
|
|
|
# Act / Assert
|
|
self.helper_save_as_pdf(mode)
|
|
|
|
def test_rgb(self):
|
|
# Arrange
|
|
mode = "RGB"
|
|
|
|
# Act / Assert
|
|
self.helper_save_as_pdf(mode)
|
|
|
|
def test_p_mode(self):
|
|
# Arrange
|
|
mode = "P"
|
|
|
|
# Act / Assert
|
|
self.helper_save_as_pdf(mode)
|
|
|
|
def test_cmyk_mode(self):
|
|
# Arrange
|
|
mode = "CMYK"
|
|
|
|
# Act / Assert
|
|
self.helper_save_as_pdf(mode)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|
|
|
|
# End of file
|