In the "Dreaming Big Dreams" post I asked, Why can't we put unit tests near
the code being tested?
In the "Unit Testing Nodes" thread I suggested two ways to put unit tests
near code:
1. Use doctests. The node will end with something like:
doctest.run_docstring_examples(factorial, globals(), name='factorial')
2. Use explicit unit tests. The node will end with something like:
suite = unittest.TestLoader().loadTestsFromTestCase(TestFactorial)
unittest.TextTestRunner(verbosity=1).run(suite)
These solutions have two important drawbacks:
- They don't take full advantage of Leo's @test nodes. Tests have to be
defined in the usual Python manner.
- The test-running code shown above would have to be disabled if it were
incorporated into a .py file.
When I asked, "Why can't we put unit tests near the code being tested?" I
already had in mind a more ambitious answer:
*Leo outlines could benefit from a third dimension.*
For example, within an @file or @clean tree, we want to be able to define
@test nodes in such a way that they *weren't* written to the external file,
but in other respects were treated as part of the outline. This would
eliminate the need to add the testing code given above. We devs could run
@test or @suite nodes as usual. Do you see?
Alas, this seems impossible. Special cases for @test or @suite (or *any*
other kind of node) affect Leo's fundamental read code. The read code for
@file deletes all nodes in the outline before the read. Doing so seems
essential. Adding special cases to @clean would seem to require drastic
changes to the @clean update algorithm.
In other words, adding extra dimensions to the outline would be a huge
change, as I envisage it at present. I'll keep this issue in the back of
my mind, but without big Aha's this is never going to happen.
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 https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.