[Grok-dev] Re: where do I put doctests for my models?
Brandon Craig Rhodes
brandon at rhodesmill.org
Tue Aug 7 14:07:20 EDT 2007
Uli Fouquet <uli at gnufix.de> writes:
> I'd place doctests into the source itself or txt-files, such
> avoiding another filename extension. It's fairly simple to scan a
> package for such files and do an automated testing out-of-the-box.
> However, I am not sure, whether this would be too much black magic.
My desire is simply to have Grok support testing with the exact same
amount of "magic" which it currently uses for modules. :-)
When my application runs, Grok recursively searches my directories to
find code - which is "magic" from the point of view of strict Python;
normally, in Python, you have to define __all__ in your __init__.py to
allow someone to dynamically discover your sub-modules.
But Grok's "magic" is *not* "black magic", because it is - in my
experience, at least - never confusing: the new user quickly learns
that anything named "*.py" located anywhere in a module under "app"
will get grokked. So he learns not to place ".py" files under his
application that he is not intending on using!
The rule that "./bin/test runs, as a doctest, every .txt file that it
can find under your app/ directory" would be, to me, exactly the same
kind of magic that Grok already provides for modules. It would
confuse me - in fact, it did confuse me! - when the first .txt files I
added to my application were not auto-discovered by "./bin/test",
because I had assumed that everything in Grok would follow the same
rule: a recursive descent of my modules directories, looking for
things to process.
--
Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev
mailing list