python - How to use different fixtures with different data structures for one test in pytest? -
i have test uses smoke test fixture covers subset of full test fixture. 1 part of testing, i'd use smoke test fixture test, if want big test i'd use full test fixture employs different data structure (in case below, small uses tuples , big uses list). have test using 1 fixture shown below , i'm having trouble figuring out how interchange between fixtures different data structures.
import pytest @pytest.fixture(params=[ (1, 1), (2, 2) ]) def small_fixture_of_numbers(request): # returns list of pairs of numbers smoke testing return request.param @pytest.fixture(params=[ 1, 2, 3, 4 ]) def big_fixture_of_numbers(request): # returns full list of numbers full-scale testing return request.param def test_addition(small_fixture_of_numbers): (x, y) = small_fixture_of_numbers total = x + y assert total > 2
it not wise have same test run differently. less if different runs backed different data structures.
the whole idea of test case provides stable environment code run under same conditions, each time. test , fixture should fixed partners, changes in code behavior factor.
in other words, seem need 2 different tests. choice should of test run, not how run it.
Comments
Post a Comment