You could define a fixture that is automatically supplied to each test case:
import pytest
@pytest.fixture(autouse=True)
def record_index(record_xml_attribute):
record_xml_attribute('index', '15')
Note record_xml_attribute
is not supported for xunit2, the default junit_family for pytest v6. To use record_xml_attribute
with pytest v6, in pytest.ini
set
[pytest]
junit_family = xunit1