bfirsh/needle — pull request #4 by acdha (2013-05-08 18:56:28+00:00)
Title: Combined changes: refactored helpers, support alternative tools

This is my working branch with various changes:
* Refactored Selenium setup into a setUpClass method, which dramatically
improves run-time since the Selenium session overhead is massive
* Allow baseline-capture to be requested by `NEEDLE_CAPTURE` env. variable
* Select a browser other than Firefox using the `NEEDLE_BROWSER` env.
variable
* Store screenshots in `screenshots/` subdirectory; allow overriding
by setting the `NEEDLE_OUTPUT_DIR` and `NEEDLE_BASELINE_DIR` env.
variables
* Automatically create output/baseline directories if they do not exist
* Refactor `assertScreenshot` core into `compareScreenshot` context
manager which allows the check for a baseline image to be done before
actually loading the page in a browser which is much faster when
only a small percentage of the baseline images need to be re-captured
* Set `NEEDLE_USE_PERCEPTUALDIFF` to use http://pdiff.sf.net instead of
the built-in comparison
* Force the Selenium browser viewport to be a specific size (defined as
the `TestCase` `viewport_height` and `viewport_width` class
properties) which makes cross-browser/platform image comparison more
realistic as e.g. scrollbar dimensions won't cause all of the images
to be different width.