Using "proper" (text-based) unit tests is a revolution. I am embarrassed by all the cruft in unitTest.leo and leoTest.py. What was I thinking?
unitTest.leo *gets in the way of unit testing:* - The test runners in leoTest.py are inferior to the test runners in unittest and pytest. - @test nodes are inferior to test functions and classes. - Tests in unitTest.py can interfere with each other in subtle ways. The unit tests in leo/unittests/commands/editCommands.py show how easy it is to use unit tests to test Leo itself: The create_app function (in leoTest2.py) is the *only* needed support. It creates a fully functional Leo app *outside* of Leo, binding g.app to the created app. Perhaps this is what I missed so many years ago. The typical setUpClass method just calls create_app. Thereafter, setUp methods can create a commander as follows: self.c = leoCommands.Commands(fileName=None, gui=g.app.gui) And away we go. Tests have full access to g.app, g.app.gui, and a fully functional commander, c. *New directions* The new testing world suggests three major improvements: 1. Create tests for the console gui. There is no need to run these unit tests from plugins/cursesGui2.py! 2. Create tests for Qt gui. There is no need to run these tests from unitTest.leo! 3. Remove g.app.unitTesting and g.unitTesting. There is no need to disable traces, etc. when running tests outside of Leo. Much better to make tests dependent on --trace values. *Acknowledgment* I spent considerable time last week on more complicated schemes for the new unit tests. That complexity eventually collapsed. Only create_app remains. That collapse would likely not have happened were it not for Brian's comment <https://groups.google.com/g/leo-editor/c/DTUe32_WhUs/m/duDmZOPEBQAJ>: "I tend to favor composition over inheritance and functions over classes. The fixture feature helps with this preference." Thanks, Brian. Now I see that @test x is precisely equivalent to def test_x. Oh my, I have wasted so much time on feeble substitutes for features of python's unittest module. *Summary* *Nothing *is gained by unitTest.leo, @test, and leoTest.py. The new testing world is better all ends up. When running tests from the command line, the create_app function in leoTest2.py gives unit tests full access to all of Leo's source code. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/1c548ce9-69e0-442f-b983-9d2d455bc811n%40googlegroups.com.
