[PyQt] ANN: update to check_widget_snapshot() for widget appearance testing

oliver oliver.schoenborn at gmail.com
Mon Nov 28 04:10:27 GMT 2016


A couple months ago I created a function check_widget_snapshot() that I
discussed on codeproject, and announced it on the mailing list (see the
archives at
http://python.6.x6.nabble.com/Recipe-for-testing-with-snapshots-in-pyqt-tt5200821.html).
I have since extended its functionality significantly and put it on github
in https://github.com/schollii/sandals/blob/master/pyqt_test_sandals.py.

The check_widget_snapshot() function makes it really easy to test that PyQt
widget appearance has not changed since last time a test ran: if
check_widget_snapshot() is called on a widget for which a snapshot has not
been saved, the function creates the snapshot and saves to filesystem;
otherwise, it compares the current widget's grab() against the saved file
and, if different, it saves the actual and diff files and computes some
metrics about the differences.

Although the check_widget_snapshot() code is tested with 100% coverage and
is used in an actual project, some details could still change, esp. with
regards to the generation of the difference image. Dependency injection can
be used to customize the metrics and diff image computed.

Feedback and contributions welcome!
Oliver

-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161128/be60d387/attachment.html>


More information about the PyQt mailing list