[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Recipe for testing with snapshots in pyqt
From: oliver <oliver.schoenborn () gmail ! com>
Date: 2016-09-30 16:44:58
Message-ID: CAMb+DaU+8KkZWW19ib-X=hBGfSNh5HOh5CkjnzJw83-DHt=SQg () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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
[Attachment #5 (text/html)]
<div dir="ltr">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: <br><div><br></div><div><a \
href="http://www.codeproject.com/Tips/1134902/Testing-QWidget-Snapshot-Regression-in-P \
yQt">http://www.codeproject.com/Tips/1134902/Testing-QWidget-Snapshot-Regression-in-PyQt</a><br \
clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div \
dir="ltr"><div><font size="2" style="font-size:small"><br></font></div><div><font \
size="2" style="font-size:small">Super easy to use: </font></div><div><font size="2" \
style="font-size:small"><br></font></div><div><pre lang="python" id="gmail-pre45406" \
class="gmail-notranslate" \
style="color:rgb(0,0,0);background-color:rgb(251,237,187);padding:6px;font-stretch:normal;font-size:9pt;line-height:normal;font-family:consolas,"courier \
new",courier,mono;white-space:pre-wrap;border:1px solid \
rgb(251,237,187);overflow:auto;word-wrap:break-word;word-break:break-word;margin-top:0px"><span \
class="gmail-code-string" \
style="margin:0px;padding:0px;border:0px;color:rgb(128,0,128)">app = QApplication([]) \
widget = QLabel('test') assert check_widget_snapshot(widget, folder, \
'label')</span></pre></div><div><font size="2" style="font-size:small">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. </font></div><div><font size="2" \
style="font-size:small"><br></font></div><div><font size="2" \
style="font-size:small">In some cases (might be most, not sure yet), no need to even \
wait for app.exec() to start!. </font></div><div><font size="2" \
style="font-size:small"><br></font></div><div><font size="2" \
style="font-size:small">Feedback welcome.</font></div><div><font size="2" \
style="font-size:small">Oliver</font><div style="font-size:small"><font size="1">Open \
Source contributions: <a href="http://pubsub.sf.net/" style="color:rgb(17,85,204)" \
target="_blank">PyPubSub</a>,</font><span style="font-size:x-small"> </span><a \
href="https://github.com/schollii/nose2pytest" \
style="color:rgb(17,85,204);font-size:x-small" target="_blank">nose2pytest</a><span \
style="font-size:x-small">,</span><span style="font-size:x-small"> L</span><a \
href="http://lua-icxx.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" \
target="_blank">ua-iCxx</a><span style="font-size:x-small">, </span><a \
href="http://iof.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" \
target="_blank">iof</a></div><div style="font-size:small"><font size="1"><a \
href="http://stackoverflow.com/users/869951/schollii" style="color:rgb(17,85,204)" \
target="_blank">StackOverflow</a> contributions</font></div></div><div><font \
size="1"><br></font></div><div></div></div></div></div></div></div></div> \
</div></div>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic