Reputation: 33
I have a test class with 2 tests. How can I parametrize whole class while having one test parametrized additionally?
I need test_b
executed 1 time for param0
and 2 times for param1
Module threads.py
Class TestThreads
Function test_a[param0]
Function test_b[param0-0]
Function test_a[param1]
Function test_b[param1-0]
Function test_b[param1-1]
Upvotes: 1
Views: 2451
Reputation: 563
You can parameterise both class and methods individually and they stack together. For example, to get the outcome you describe, you can parameterise the class with param0, and parameterise test_b with param1:
import pytest
@pytest.mark.parametrize("param0", [0])
class TestThreads:
def test_a(self, param0):
assert True
@pytest.mark.parametrize("param1", [0, 1])
def test_b(self, param0, param1):
assert True
Upvotes: 1