Skip to content
Advertisement

how to execute multiple tests on multiple items with py.test

I’m a novice in python and also in py.test. I’m searching a way to run multiple tests on multiple items and cannot find it. I’m sure it’s quite simple when you know how to do it.

I have simplified what I’m trying to do to make it simple to understand.

If I have a Test class who defines a serie of tests like this one :

JavaScript

I want to execute this SeriesOfTest on each item obtained from a function like :

JavaScript

The result i’m trying to obtain is something like :

JavaScript

How can I do this with py.test?

Than you guys (and girls also)

André

Advertisement

Answer

Forget about the previous answer. Given that you need the tests to be grouped by value, you can use scenarios. I’ve just adapted the example from the docs:

JavaScript

And the output is:

JavaScript

I think that’s the closest you can get.

Advertisement