On Sun, Dec 22, 2019 at 12:45 AM Matt Wilkie <[email protected]> wrote:
> My fix pushed to devel with 016867f > <https://github.com/leo-editor/leo-editor/commit/016867f5ade5da6796397ab4705287bf8b8f336a> > . > > Things I learned exploring this issue: > > - Leo's *g *global module contains the python *os*, *sys*, and *subprocess > *modules, so they don't need to be initialized (imported) in order to > use them. > - g.app.leoDir == *leo-editor/leo*, and g.app.loadDir == > *leo-editor/leo/core*. > - *./leo/core/runLeo.py* is the real work horse for starting Leo. > (I've often been confused about just how/where Leo is started.) > - Leo needs to be restarted in order to pick up changes in this core > file (probably true generally) > - I really am able to identify, locate and fix a bug in Leo within an > area I have no previous experience in! (At least once anyway. ;-) > > Excellent summary, and congratulations on exploring previously uncharted territory. In general, it is manifestly impossible to use importlib.reload on Leo's core because reload does not update Leo's data structures. Some unit tests have a "preamble" that calls importlib.reload, but those are rare exceptions. Search for "preamble" in unitTest.leo. > What I still need to learn: how to write and run Leo unit tests. > It's easy. Just open unitTest.leo. To see the default bindings, do <alt-x>run-<tab>. Don't bother running unit tests externally. As I write this I am wondering whether the run-*-externally commands could be retired... Alt-4 runs all unit tests in the selected outline. To run all the standard unit tests, select the node "Active Unit Tests" at the top level. Alt-5 runs all the *marked *unit tests. I typically use Alt-5 when developing unit tests, because then I don't have to select the desired node. @test nodes create unit tests, without all the bother of creating an instance of unittest.TestCase. The @test startup code creates that instance automagically. The simplest unit test: @test pass pass Select the node, hit Alt-4, see the results in the console. Within @test nodes, c, g and p are bound as usual. More importantly, "self" is bound to the created instance of unittest.TestCase. So you can use self.assert*, and self.skipTest(reason) if the test depends on conditions that aren't met. unitTest.leo contains hundreds of examples. You can browse through them if you like looking for tricks :-) 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/CAMF8tS0sqh48-Ric9aj4pw2y8YSZ%3DAcAshRfwh2ERX%3DNXQZ7KQ%40mail.gmail.com.
