python-pillow/Pillow — pull request #693 by hugovk (2014-06-05 09:23:25+00:00)
Title: Start using unittest for tests

I spotted in `PIL/tests.py` the idea to start moving the tests to use the `unittest` module. Here's a start.

Notes:
* Rather that putting them under `PIL/` it's better they have their own directory. A common one is `tests/` but we have the old ones in `Tests/` so I'm putting them in `test/` to make it clear which are which.
* 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`:
* No coverage: `nosetests test/`
* With coverage: `coverage run --append --include=PIL/* -m nose test/`
* `helper.py` still has a lot of commented out stuff from `tester.py`. I'm uncommenting and updating things as needed, so no commented stuff will be left at the end.

TODO:
* Convert the rest.
* Implement `tempfile()` and cleanup.
* The old tester deletes files at the end of `test_something.py` unless the test failed.
* At the end of the whole test suite, it prints out any remaining temp files.

Any comments?