[Tutor] Questions as to how to run the same unit test multiple times on varying input data.
Ben Finney
ben+python at benfinney.id.au
Sat Sep 24 03:04:37 EDT 2016
Bob, you may want to also subscribe to the specific forum for testing in
Python <URL:http://lists.idyll.org/listinfo/testing-in-python>. You're
beyond the beginner material that's usually discussed on this Tutor forum.
boB Stepp <robertvstepp at gmail.com> writes:
> What I struggled with was getting tests to run for ALL of the data.
> Until I found subTest in the docs, the tests would stop with the FIRST
> failure, whereas I wanted to see ALL failures and passes. That is, I
> wanted to exercise all of the data inputs and see the collected
> results.
The ‘testscenarios’ third-party package is designed for this
<URL:https://pypi.python.org/pypi/testscenarios/>.
You define “scenarios” of data to apply to each of the test case
functions in a class; the ‘testscenarios’ magic is then to multiply
those functions, at run time, by each of the scenarios. A separate test
case will be generated for each combination, with its own distinct
result reported in the test run.
To discuss more, join us over at the testing-in-python forum
<URL:http://lists.idyll.org/listinfo/testing-in-python>.
--
\ “Courage is resistance to fear, mastery of fear — not absence |
`\ of fear.” —Mark Twain, _Pudd'n'head Wilson_ |
_o__) |
Ben Finney
More information about the Tutor
mailing list