У меня есть приспособление, которое загружает данные.
Код: Выделить всё
import pytest
@pytest.fixture(scope="function")
def param_data(request):
with open(f'tests/fixtures/{request.param}.json') as f:
return json.load(f)
[*]tests/fixtures /data1.json
[*]tests/fixtures/data2.json
[*]tests/fixtures/data3.json
Как это сделать с помощью @pytest.mark.parameterize? Я имею в виду...
Код: Выделить всё
@pytest.mark.parametrize(???)
def test_my_function(dict, expected):
# Test my_function() with the dict loaded by fixture and the expected result.
assert my_function(dict) == expected
И все видимые мной фикстуры фиксируются с помощью возврата значения, а не с использованием request.param
код>.
Подробнее здесь: https://stackoverflow.com/questions/792 ... arametrize