I am actively using record_xml_property fixture in my tests, but unfortunately it just does not work with xdsit plugin. I've tried to implement a workaround. Instead of directly add properties to the reporter, I put them to the slaveoutput:
@pytest.fixture
def record_xml_property(request):
xml = getattr(request.config, "_xml", None)
if xml is not None:
node_reporter = xml.node_reporter(request.node.nodeid)
return node_reporter.add_property
else:
def add_property_xdist(name, value):
request.node.config.slaveoutput.update({'properties': {name: value}})
return add_property_xdist
And after that I wanted to add this properties to the report in pytest_runtest_logreport
hook:
@pytest.hookimpl(tryfirst=True)
def pytest_runtest_logreport(report):
if report.when != 'teardown':
return
node = getattr(report, 'node', None)
if not node:
return
xml = getattr(node.config, '_xml', None)
if not xml:
return
node_reporter = xml.node_reporter(report)
slaveoutput = getattr(node, 'slaveoutput', None)
if not slaveoutput:
return
node_properties = slaveoutput.get('properties', {})
for key, value in node_properties.items():
node_reporter.add_property(key, value)
But the problem is that slaveoutput usually is not available in SlaveController
object yet when pytest_runtest_logreport
hook is executed. It is available in pytest_testnodedown
, SlaveInteractor
sends it with "slavefinished"
event, but at this moment reports are finalized already. Is there any way to get slaveoutput from slave node earlier?