parametized unittest
Roy Smith
roy at panix.com
Sat Jan 11 23:34:30 EST 2014
In article <mailman.5355.1389500996.18130.python-list at python.org>,
"W. Trevor King" <wking at tremily.us> wrote:
> On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote:
> > I'm finding it hard to use unittest in a for loop. Perhaps something like:
> >
> > for val in range(25):
> > self.assertEqual(val,5,"not equal)
> >
> > The loop will break after the first failure. Anyone have a good
> > approach for this? please advise.
>
> If Python 3.4 is an option, you can stick to the standard library and
> use subtests [1].
Or, as yet another alternative, if you use nose, you can write test
generators.
https://nose.readthedocs.org/en/latest/writing_tests.html#test-generators
More information about the Python-list
mailing list