[TIP] Test Parameterization with unittest
fuzzyman at voidspace.org.uk
Tue May 12 04:12:17 PDT 2009
Robert Collins wrote:
> On Mon, 2009-05-11 at 17:33 +0100, Michael Foord wrote:
>> Yeah - that's a nicer API for having multiple scenarios in a single test
>> class. I'll read about it and propose something for unittest.
> I'd be happy to just include it in the stdlib.
Scenarios seem very good for interface testing (when you want to run a
whole set of tests against different backend implementations of the same
They are not an equivalent of generative tests, which people seem to
like from nose / py.test.
I'm also not wild about specifying a dictionary of parameters which then
'magically' become instance attributes. It would make me antsy writing
tests that use attributes which don't exist until they are stuck onto
I like the *mechanism* of TestWithScenarios though. I'd prefer to
specify a test method and have it called with arguments from the
scenario. I might update my metaclass recipe to do something like this.
Although it isn't suitable for going into unittest.py it is perfectly
I wonder which is more generally needed in unittest - generative tests
or interface tests?
As I don't have a personal need for *either* I think I should avoid
trying to push something into the standard library. It is a subject to
revisit as it seems like a gap in unittest.
More information about the testing-in-python