Pillow/Tests/test_file_pdf.py

60 lines
1.1 KiB
Python
Raw Normal View History

2014-09-05 13:36:24 +04:00
from helper import unittest, PillowTestCase, hopper
2014-05-11 10:01:09 +04:00
2014-06-10 13:10:47 +04:00
import os.path
2014-05-11 10:01:09 +04:00
2014-06-10 13:10:47 +04:00
class TestFilePdf(PillowTestCase):
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
def helper_save_as_pdf(self, mode):
# Arrange
2014-09-05 13:36:24 +04:00
im = hopper(mode)
2014-06-10 13:10:47 +04:00
outfile = self.tempfile("temp_" + mode + ".pdf")
2014-06-10 13:10:47 +04:00
# Act
im.save(outfile)
2014-05-11 18:35:49 +04:00
2014-06-10 13:10:47 +04:00
# Assert
self.assertTrue(os.path.isfile(outfile))
self.assertGreater(os.path.getsize(outfile), 0)
2014-05-11 18:35:49 +04:00
2014-06-10 13:10:47 +04:00
def test_monochrome(self):
# Arrange
mode = "1"
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
# Act / Assert
self.helper_save_as_pdf(mode)
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
def test_greyscale(self):
# Arrange
mode = "L"
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
# Act / Assert
self.helper_save_as_pdf(mode)
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
def test_rgb(self):
# Arrange
mode = "RGB"
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
# Act / Assert
self.helper_save_as_pdf(mode)
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
def test_p_mode(self):
# Arrange
mode = "P"
2014-05-12 15:45:54 +04:00
2014-06-10 13:10:47 +04:00
# Act / Assert
self.helper_save_as_pdf(mode)
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
def test_cmyk_mode(self):
# Arrange
mode = "CMYK"
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
# Act / Assert
self.helper_save_as_pdf(mode)
2014-05-11 18:16:13 +04:00
2014-06-10 13:10:47 +04:00
if __name__ == '__main__':
unittest.main()
2014-05-11 18:16:13 +04:00
2014-05-11 10:01:09 +04:00
# End of file