[Grok-dev] Re: where do I put doctests for my models?

Brandon Craig Rhodes brandon at rhodesmill.org
Tue Aug 7 10:08:47 EDT 2007


Brandon Craig Rhodes <brandon at rhodesmill.org> writes:

> I have written a Grok Model and now need to know where to put its
> doctest so that it gets run when I type "./bin/test". ...

I have done some more work on my question; PvW's book was helpful.
The answer to my question seems to be that Grok does not currently
give any help to the developer who wants testing - that there exists
almost no "convention", but almost entirely "configuration".

Could I submit a tutorial showing the current state-of-the-art in
building tests for a Grok app, so that other beginners have somewhere
to start from?

To get a doctest to run in my Grok buildout when I type "./bin/test",
the following seems necessary:

 - I must create a directory called "tests" in my app.
 - I must create an __init__.py in that directory.
 - I must create files with names like test*.py in the directory.
 - Those files must have functions or classes in them named test_*.
 - Those functions or classes must "from doctest import DocFileSuite"
   and then list, filename by filename, all of my doctest files; or
   I have to write my own recursive-descent routine (the grok tests
   themselves seem to do this) to search for tests in my app.

I humbly suggest that all of the above is a massive example of
configuration over convention - the programmer has to perform about
six steps, each of which must be done perfectly correctly, before the
"./bin/test" command becomes willing to run his tests.

Would it be possible for the "test" command in a Grok buildout to
automatically search for tests, instead of making the developer write
his own "test_app.py" module?  I would love to be able to drop dozens
of ".doctest" files in my "tests" directory inside my app, and have
them just magically get run when I type "./bin/test".

I am willing to help code this, but am not sure what should change -
the code of "./bin/test" itself, or something else?

-- 
Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon


More information about the Grok-dev mailing list