[PyQt] Recipe for testing with snapshots in pyqt
oliver
oliver.schoenborn at gmail.com
Fri Sep 30 17:44:58 BST 2016
Recipe that can be included in a pytest or nose test suite to compare
appearance of widget with reference saved on disk, or generate the
references that don't exist:
http://www.codeproject.com/Tips/1134902/Testing-QWidget-Snapshot-Regression-in-PyQt
Super easy to use:
app = QApplication([])
widget = QLabel('test')
assert check_widget_snapshot(widget, folder, 'label')
will generate label.png in folder for widget if it doesn't exist; if it
exists, it will load it and compare current widget.grab(). If it finds an
RMS of the differences to be > tolerance (default 0, not shown), it will
geneate a diff, here it would be called label_diff.png, to help
troubleshoot.
In some cases (might be most, not sure yet), no need to even wait for
app.exec() to start!.
Feedback welcome.
Oliver
Open Source contributions: PyPubSub <http://pubsub.sf.net/>, nose2pytest
<https://github.com/schollii/nose2pytest>, Lua-iCxx
<http://lua-icxx.sf.net/>, iof <http://iof.sf.net/>
StackOverflow <http://stackoverflow.com/users/869951/schollii> contributions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160930/ad520627/attachment.html>
More information about the PyQt
mailing list