[Grok-dev] Re: martian.scan changed
uli at gnufix.de
Fri Aug 17 18:59:24 EDT 2007
Am Freitag, den 17.08.2007, 22:16 +0200 schrieb Martijn Faassen:
> Sorry about being obscure!
It was my English, not your explanation. Sorry for being dumb ;-)
> JW is on vacation, but we should let him speak about his use case.
> *believe* his motivation to have grok *not* look in tests or ftests
> was so that test-setup code that might subclass from a Grok class
> wouldn't be grokked during the main program execution. You don't want
> classes that are there purely for testing purposes (and that are
> manually grokked) to be picked up while your application is running.
Then I think I understood correctly. I'd agree to have it this way,
because I had some trouble with it as well (for instance my
grok.Applications in tests showed always up in the 'Install new
application' select box. I found another, nasty, workaround, which would
not have been neccessary with JWs changes). So basically I appreciated
JWs changes in grok behaviour very much!
> This makes sense. When we collect tests however, we *would* want to
> explicitly grok tests and ftests for tests (or perhaps even only
> them). Since the test-grokking would happen during another phase
> (test-collection) than the main-execution grokking, this contradiction
> may in fact not be a problem.
Well, tests can grok themselves and better decide, what they want to
have grokked. I see no problem here. We only need a hook for them, but
this is more a problem of test-setup and a discussion we don't need to
perpetuate here ;-)
To have the by-default-only-non-test-packages-are-grokked behaviour
back, I see two solutions:
1) rolling back my changes of yersterday. No worries about the
dependency. A fix costs only half a minute. JW already implemented
optional parameters to include tests. In this case, I was too hasty.
2) setting up the _grokkers_ (instead of the generic scanner), so that
they do not grok tests by default (we want tests not automatically to be
included when things are _grokked_, not when they are _scanned_,
right?). IMHO it should be sufficient to modify grok_package() minimal
to grok only modules not named `f/tests`. Thus, we might have the same
behaviour as before my overhasty changes, but triggered by 'Grokkers'
and not by a generic module scanner. From my point of view this would be
more consistent and keep martian.scan as generic as it was in the
There might be a smarter way, though.
More information about the Grok-dev