вот мой код параметризации:
Код: Выделить всё
def pytest_generate_tests(metafunc):
# Check if the function or class is marked with 'plan'
#logging.info(metafunc.config.getoption("--buildno"))
test_plan = load_test_data()
if test_plan['testType'] == 'plan':
if "suite_data" in metafunc.fixturenames:
if "testPlan" in test_plan and "testSuites" in test_plan["testPlan"]:
test_suites = test_plan["testPlan"]["testSuites"]
metafunc.parametrize("suite_data", test_suites, ids=[suite["testSuiteID"] for suite in test_suites])
else:
raise KeyError("Missing 'testSuites' in 'testPlan'")
Код: Выделить всё
class TestPlanRunner:
@pytest.mark.plan
def test_plan_runner(self, test_build_runner_config, suite_data):
test_plan = test_build_runner_config.get_test_plan()
suite_id = suite_data.get("testSuiteID")
suite_data = next(suite for suite in test_plan["testSuites"] if suite["testSuiteID"] == suite_id)
result = template_test_suite_run(test_build_runner_config, suite_data)
suite_data['result'] = result
all_suites_passed = True
if not suite_data['result']:
all_suites_passed = False
test_plan_id = test_plan['testPlanID']
if all_suites_passed:
data = {'testPlanID': test_plan_id, 'result': 'passed'}
update_plan_result(data)
else:
data = {'testPlanID': test_plan_id, 'result': 'failed'}
update_plan_result(data)
logger.info(f">>>>>> TEST PLAN RESULT: {data}
Подробнее здесь: [url]https://stackoverflow.com/questions/79032725/how-can-i-append-test-results-from-parallel-execution-in-pytest-xdist[/url]