2014-06-10 13:10:47 +04:00
|
|
|
from helper import unittest, PillowTestCase, tearDownModule, lena
|
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
|
|
|
|
im = lena(mode)
|
|
|
|
outfile = self.tempfile("temp_" + mode + ".pdf")
|
2014-05-12 15:30:03 +04:00
|
|
|
|
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
|