junitxml: follow Bruno's attribute/method naming hint from the review

This commit is contained in:
Ronny Pfannschmidt 2015-10-14 12:30:56 +02:00
parent 5eef6a2821
commit 0aa54101c9
1 changed files with 14 additions and 14 deletions

View File

@ -202,8 +202,8 @@ def record_xml_property(request):
) )
xml = getattr(request.config, "_xml", None) xml = getattr(request.config, "_xml", None)
if xml is not None: if xml is not None:
nodereporter = xml.nodereporter(request.node.nodeid) node_reporter = xml.node_reporter(request.node.nodeid)
return nodereporter.add_property return node_reporter.add_property
else: else:
def add_property_noop(name, value): def add_property_noop(name, value):
pass pass
@ -260,16 +260,16 @@ class LogXML(object):
'failure', 'failure',
'skipped', 'skipped',
], 0) ], 0)
self.nodereporters = {} # nodeid -> _NodeReporter self.nodere_porters = {} # nodeid -> _NodeReporter
self.nodereporters_ordered = [] self.nodere_porters_ordered = []
def nodereporter(self, nodeid): def node_reporter(self, nodeid):
if nodeid in self.nodereporters: if nodeid in self.nodere_porters:
#TODO: breasks for --dist=each #TODO: breasks for --dist=each
return self.nodereporters[nodeid] return self.nodere_porters[nodeid]
reporter = _NodeReporter(nodeid, self) reporter = _NodeReporter(nodeid, self)
self.nodereporters[nodeid] = reporter self.nodere_porters[nodeid] = reporter
self.nodereporters_ordered.append(reporter) self.nodere_porters_ordered.append(reporter)
return reporter return reporter
def add_stats(self, key): def add_stats(self, key):
@ -277,7 +277,7 @@ class LogXML(object):
self.stats[key] += 1 self.stats[key] += 1
def _opentestcase(self, report): def _opentestcase(self, report):
reporter = self.nodereporter(report.nodeid) reporter = self.node_reporter(report.nodeid)
reporter.record_testreport(report) reporter.record_testreport(report)
return reporter return reporter
@ -319,13 +319,13 @@ class LogXML(object):
reporter.append_skipped(report) reporter.append_skipped(report)
self.update_testcase_duration(report) self.update_testcase_duration(report)
if report.when == "teardown": if report.when == "teardown":
self.nodereporter(report.nodeid).finalize() self.node_reporter(report.nodeid).finalize()
def update_testcase_duration(self, report): def update_testcase_duration(self, report):
"""accumulates total duration for nodeid from given report and updates """accumulates total duration for nodeid from given report and updates
the Junit.testcase with the new total if already created. the Junit.testcase with the new total if already created.
""" """
reporter = self.nodereporter(report.nodeid) reporter = self.node_reporter(report.nodeid)
reporter.duration += getattr(report, 'duration', 0.0) reporter.duration += getattr(report, 'duration', 0.0)
def pytest_collectreport(self, report): def pytest_collectreport(self, report):
@ -337,7 +337,7 @@ class LogXML(object):
reporter.append_collect_skipped(report) reporter.append_collect_skipped(report)
def pytest_internalerror(self, excrepr): def pytest_internalerror(self, excrepr):
reporter = self.nodereporter('internal') reporter = self.node_reporter('internal')
reporter.attrs.update(classname="pytest", name='internal') reporter.attrs.update(classname="pytest", name='internal')
reporter._add_simple(Junit.error, 'internal error', excrepr) reporter._add_simple(Junit.error, 'internal error', excrepr)
@ -356,7 +356,7 @@ class LogXML(object):
logfile.write('<?xml version="1.0" encoding="utf-8"?>') logfile.write('<?xml version="1.0" encoding="utf-8"?>')
logfile.write(Junit.testsuite( logfile.write(Junit.testsuite(
[x.to_xml() for x in self.nodereporters_ordered], [x.to_xml() for x in self.nodere_porters_ordered],
name="pytest", name="pytest",
errors=self.stats['error'], errors=self.stats['error'],
failures=self.stats['failure'], failures=self.stats['failure'],