Question

As a small part of a much larger set of tests, I have a suite of test functions I want to run on each of a list of of objects. Basically, I have a set of plugins, and a set of "plugin tests".

Naively, I can just make a list of test functions that take a plugin argument, and a list of plugins, and have a test where I call all of the former on all of the latter. But ideally, each test/plugin combo would appear as an individual test in the results.

Is there already a nicer/standardized way of doing something like this in pytest?

Was it helpful?

Solution

Check out pytest's documentation on parametrization (https://pytest.org/latest/parametrize.html).

It's a mechanism for running the same test a number of times with different parameters -- it sounds like just what you want. It generates tests that run individually, and they have nice output and reporting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top