[TIP] Meta-test methods...
dgou at mac.com
Wed Apr 22 12:03:23 PDT 2009
I noticed that py.test (and maybe nose, I haven't looked yet) has a
way for a "test method" to return test messages.
The py.test mechanism uses some groddy checks to see if a test method
is really a generator.
Granted a generator does not make sense as a test method...
This is a facility I need to introduce to our slightly customized
version of test unit.
At first I was smitten by the "coolness" of using a generator and the
automatic detection thereof.
Then I remembered: import this's "Explicit is better than implicit."
And so I thought, well, rather than grunging around in various
implementation details like py.test does, to determine if a method is
a generator, I should use a decorator.
With a decorator why I can even write a meta-test method that returns
(Horrors!) a list! Or a set, or a tuple.
The only thing I haven't decided upon, and hence this note to the
list, is what to name the decorator.
Has anyone else done this? Have a good name to suggest?
More information about the testing-in-python