python-pillow/Pillow — pull request #699 by hugovk (2014-06-10 12:42:52+00:00)
Title: Use unittest for tests

Replaces https://github.com/python-pillow/Pillow/pull/693 and preserves history.

Notes:
* The old `tester.py` is now `helper.py` and contains helper functions like `lena()` and a base class `PillowTestCase(unittest.TestCase)`.
* unittest.TestCase has many [assert functions](https://docs.python.org/2/library/unittest.html#assert-methods) for Python 2.7 onwards. For Python 2.6 we use `unittest2` which has them backported.
* `PillowTestCase` defines the extra asserts like `assert_image_equal()`.
* Individual `test/test_*.py` files have a test class that derives from `PillowTestCase` so they can use `assert_image_equal()` and so on.
* Individual `test/test_*.py` have `if __name__ == '__main__': unittest.main()` so they can be individually run: `python test/test_something.py`
* To run the whole batch (e.g. on Travis CI) it uses `nosetests` (see `.travis.yml` for latest command):
* No coverage: `nosetests Tests/test_*.py`
* With coverage: `coverage run --append --include=PIL/* -m nose Tests/test_*.py`

TODO:
* [ ] `helper.py` still has some commented out stuff from `tester.py`.
* [ ] The old test runner prints out remaining temp files at the end. This new one does so when running an individual test file, but not via nose.
* [ ] `lena()` opens images fresh from disk to ensure tests are independent and repeatable. It would be better to caches images for speed (no caching is around 60% slower). What's the best way to create a 100% duplicate copy of an image? There's no point testing on a copy if it loses important information from the original.
* [ ] Send `test_olefileio.py` back upstream.
* [ ] There's some miscellaneous files still in `Tests/`. Are these still needed?
* `Tests/bench_cffi_access.py`
* `Tests/bench_get.py`
* `Tests/cms_test.py`
* `Tests/crash_ttf_memory_error.py`
* `Tests/helper.py`
* `Tests/import_all.py`
* `Tests/large_memory_numpy_test.py`
* `Tests/large_memory_test.py`
* `Tests/make_hash.py`
* `Tests/show_icc.py`
* `Tests/show_mcidas.py`
* `Tests/threaded_save.py`
* `Tests/versions.py`