[TIP] Test Parameterization with unittest

Olemis Lang olemis at gmail.com
Mon May 11 06:57:25 PDT 2009


On Sun, May 10, 2009 at 7:26 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> Michael Foord <fuzzyman at voidspace.org.uk> writes:
>
>> class Test(TestCaseWithParams):
>>     params = [(1, 1), (2, 3), (2, 2), (3, 5)]
>>
>>     def assertWithParams(self, a, b):
>>         self.assertEqual(a, b)
>
> I prefer the API for the ‘testscenarios’ library
> <URL:https://launchpad.net/testscenarios>, where each scenario has a
> name and an arbitrary dict of the scenario parameters
> <URL:http://bazaar.launchpad.net/~lifeless/testscenarios/trunk/annotate/head%3A/README>.
>
>    scenarios = [
>        ('foo', {'spam': True, 'eggs': 17, 'beans': [0, 1]}),
>        ('bar', {'spam': False, 'eggs': 23, 'beans': [1, 1, 0]}),
>        ]
>

+1 ... this is much more explicit IMHO ...

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:



More information about the testing-in-python mailing list