Running unit tests externally is, by far, the most convenient because
there is need to reload changed code.

At present, tests that use Leo's Qt gui fail when run externally
because such tests use a null gui.  That will soon change.  Indeed,
here is an "exploratory" unit test that illustrates how to set up a
test to use an almost-completely-functional environment based on the
nullGui::

    import leo.core.leoCommands as leoCommands
    import leo.core.leoFrame as leoFrame
    import leo.core.leoGui as leoGui

    # Important: external unit tests should execute in this
environment.
    nullGui   = leoGui.nullGui('null gui')
    nullFrame = leoFrame.nullFrame(title='nullFrame
title',gui=nullGui,useNullUndoer=True)
    c2 = leoCommands.Commands(nullFrame,fileName='<empty fileName>')
    nullFrame.c = c2
    body = leoFrame.nullBody(frame=nullFrame,parentFrame=None)
    assert repr(body).startswith('<leo.core.leoFrame.nullBody')

    # Now test some basic operations:
    w = body.widget
    assert repr(w).startswith('stringTextWidget')
    w2 = body.bodyCtrl
    assert w == w2
    w.setAllText(p.b)
    assert p.b == w.getAllText()

This *passes* when run externally, because the nullBody class uses a
stringTextWidget as a proxy for Leo's *wrapped* QTextBrowserWidget.

In fact, all of Leo's cores interact with the wrapped text widgets,
not the actual text widgets, so it *is* perfectly feasible to run
tests of Leo's edit commands with the null gui.

To make this work, the code that runs tests externally just need to
properly init an environment, very much as is shown above.  Once that
is in place *almost all* of Leo's unit tests should pass regardless of
whether they are run externally or locally.

One could even imagine a nullColorizer class.  Oh wait: it already
exists.  Thus, it would also be feasible to run substantial tests of
the colorizer without actually using Qt at all...

This is quite exciting.  Running unit tests externally will be quite a
bit faster than running them with Qt gui, or any other "real" gui.
But the real payoff is not having to reload unitTest.leo in order to
run tests of updated code...

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to