On Mon, Jun 10, 2013 at 6:39 PM, brian <[email protected]>wrote:

> How do I put a function in a node and execute python code that calls that
> function in another node?
>

 The answer given is good::

     exec(g.findTestScript(c, "sumNode"))
     c = sum(1,2)

A nit: to allow "c" to be reused in the script, I would probably write::

     exec(g.findTestScript(c, "sumNode"))
     n = sum(1,2)

You could call this the "off the shelf" answer, and for most purposes it
will be just fine.  However, I would like to draw your attention to
@testsetup, a new, undocumented feature for unit testing.

When executing unit tests, the code in the body of an @testsetup node will
be executed before running all *following* @test nodes (until Leo finds
another @testsetup node.)  This eliminates the need for exec statement in
@test nodes, which is a surprisingly large cleanup.

I mention this for two reasons.  First, it's a big step forward in Leo's
unit testing capabilities.  Second, something *like* it could be used in
more sophisticated applications.  Of course, this would require scanning
for @setup-something nodes somewhere, but I think this trick is worth
mentioning.

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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to