Aha! Testing Qt code is easy!

23 views
Skip to first unread message

Edward K. Ream

unread,
Sep 13, 2022, 7:14:32 AM9/13/22
to leo-editor
One of Leo's biggest Ahas has come last.

Aha! As explained in #2827, creating unit tests for Qt code is far easier than I ever imagined. PR #2840 (merged into devel) demonstrates that:

- Leo could have supported such tests ever since Leo abandoned tests based on @test nodes!

- Only one change was needed: Previously, LeoUnitTest.setUp created a null gui, regardless of g.app.gui. Now, setUp just uses g.app.gui.  That's all!

Summary

Folks, this is an earth-shaking Aha. We can easily create coverage tests for files such as qt_text.py and qt_tree.py.

However, I plan to create new tests only when new Qt bugs arise :-)

Edward

P.S. Issue #2846 suggests experimenting with testing interactive code such as Qt dialogs. #2846 will likely be the last issue included in Leo 6.7.0.

EKR

jkn

unread,
Sep 13, 2022, 12:24:31 PM9/13/22
to leo-editor
I like the comment in the issue: "... contains hopeless code".  We've all been there...

J^n
Reply all
Reply to author
Forward
0 new messages