At present, the contents of an @test node is considered to be body of the
runTest method of generalTestCase, a subclass of unittest.TestCase.
generalTestCase is defined in leoTest.py.
I would like to generalize this, so that the user can specify a different
class, say MyTestCase, which would be a subclass of generalTestCase or
TestCase. The idea would be to define an @testclass node that would
(somehow!) define a new class that could be used in other @test nodes.
I was a surprised to see that Leo already supports @testclass. Apparently
I added support for this sometime this year ;-) The body script of
@testclass nodes are executed, and they are supposed to set either
g.app.scriptDict['suite'] or g.app.scriptDict['testclass']. If the latter,
the present code gets the test suite to be executed as follows::
testclass = g.app.scriptDict.get('testclass')
suite = unittest.TestLoader().loadTestsFromTestCase(testclass)
This is all very kludgy. Afaik, there are no @testclass nodes anywhere in
Leo.
I'd like to change this to make it more flexible and useful, but first I'd
like to know whether anyone is actually using the present version of
@testclass.
Important: The static type checking (stc) project is the motivation for
this. At present, the unit testing code for stc uses this pattern::
exec(g.findTestScript(c,'@common <kind of test>'))
The code in the @common <kind of test> nodes defines the setup method for
what are, in effect, subclasses of generalTestCase. This kind of Leo hack
must be removed asap: we can't assume that most people who are interested
in stc will use Leo! There are two alternatives:
1. Write a script to turn references to exec(g.findTestScript,whatever)
into explicit subclasses of unittest.TestCase.
2. Use another pattern, say @testclass, as the basis for the script to
create explicit subclasses of unittest.TestCase.
I prefer the second approach, if possible, because it would be much more
explicit about intentions. Really, the exec hack is too ugly even for Leo
users.
All comments and suggestions welcome.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/leo-editor/-/HvF2cgl7Vh4J.
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.