Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63747

Re: parametized unittest

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: parametized unittest
Date 2014-01-12 15:22 +1100
References <c11a3b62-2053-4b6f-afda-d2df305f58e5@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.5354.1389500578.18130.python-list@python.org> (permalink)

Show all headers | View raw


CraftyTech <hmmedina@gmail.com> writes:

> I'm trying parametize my unittest so that I can re-use over and over,
> perhaps in a for loop.

The ‘testscenarios’ <URL:https://pypi.python.org/pypi/testscenarios>
library allows you to define a set of data scenarios on your
FooBarTestCase and have all the test case functions in that class run
for all the scenarios, as distinct test cases.

e.g. a class with 5 scenarios defined, and 3 test case functions, will
run as 15 distinct test cases with separate output in the report.

> The loop will break after the first failure. Anyone have a good
> approach for this? please advise.

Yes, this is exactly the problem addressed by ‘testscenarios’. Enjoy it!

-- 
 \            “Program testing can be a very effective way to show the |
  `\        presence of bugs, but is hopelessly inadequate for showing |
_o__)                              their absence.” —Edsger W. Dijkstra |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

parametized unittest CraftyTech <hmmedina@gmail.com> - 2014-01-11 20:00 -0800
  Re: parametized unittest Ben Finney <ben+python@benfinney.id.au> - 2014-01-12 15:22 +1100
  Re: parametized unittest "W. Trevor King" <wking@tremily.us> - 2014-01-11 20:28 -0800
    Re: parametized unittest Roy Smith <roy@panix.com> - 2014-01-11 23:34 -0500
      Re: parametized unittest CraftyTech <hmmedina@gmail.com> - 2014-01-12 08:57 -0800

csiph-web