python-imaging/Pillow — pull request #657 by hugovk (2014-05-11 14:59:49+00:00)
Title: Tests for saving to PDF

Some simple tests for saving as PDF.

For a given image mode, save to PDF and assert (a) the file exists and (b) is non-zero. Doesn't check the PDF contents but at least makes sure the code is exercised from beginning to end and that it produces something.

This has found two problems, and the problematic tests have been commented out with FIXMEs so the build doesn't fail.

1) Saving a P-mode image results in a TypeError:
```
File "/home/travis/build/hugovk/Pillow/PIL/PdfImagePlugin.py", line 108, in _save
colorspace = colorspace + b"> ]"
TypeError: Can't convert 'bytes' object to str implicitly
```
e.g. https://travis-ci.org/hugovk/Pillow/builds/24915249

2) Saving a 1-mode image triggers a DeprecationWarning, and any warnings cause the build to fail:
```
/home/travis/build/hugovk/Pillow/PIL/PdfImagePlugin.py:147:
DeprecationWarning: tostring() is deprecated. Please call tobytes() instead.
data = im.tostring("raw", "1")
```
e.g. https://travis-ci.org/hugovk/Pillow/builds/24916085

(This PR branch inadvertently contains PR https://github.com/python-imaging/Pillow/pull/655, let me know if you'd like me to remove it from this PR.)