e3.testsuite.report.xunit

Helpers to generate testsuite reports using the XUnit XML format.

Classes

XUnitImporter

Helper class to import results in a xUnit report into a report index.

Functions

add_time_attribute(→ None)

Optionally add a "time" attribute.

escape_text(→ str)

Escape non-printable characters from a string.

dump_xunit_report(→ None)

Dump a testsuite report to filename in the standard XUnit XML format.

read_xfails_from_yaml(→ dict[str, str])

Read a XFAILs dict from a YAML file.

convert_main(→ None)

Module Contents

e3.testsuite.report.xunit.add_time_attribute(elt: xml.etree.ElementTree.Element, duration: float | None) None

Optionally add a “time” attribute.

If duration is a float, add the corresponding “time” attribute to elt.

e3.testsuite.report.xunit.escape_text(text: str) str

Escape non-printable characters from a string.

XML documents cannot contain null or control characters (except newlines).

e3.testsuite.report.xunit.dump_xunit_report(name: str, index: e3.testsuite.report.index.ReportIndex, filename: str) None

Dump a testsuite report to filename in the standard XUnit XML format.

Parameters:
  • name – Name for the teststuite report.

  • index – Report index for the testsuite results to report.

  • filename – Name of the text file to write.

  • duration – Optional number of seconds for the total duration of the testsuite run.

class e3.testsuite.report.xunit.XUnitImporter(index: e3.testsuite.report.index.ReportIndex, xfails: dict[str, str] | None = None)

Helper class to import results in a xUnit report into a report index.

index
xfails
run(filename: str) None

Read a xUnit report and import its results in the report index.

Parameters:

filename – Filename for the XML file that contains the xUnit report.

SLUG_RE
slugify(name: str) str

Normalize a string so that it is an acceptable test name component.

Parameters:

name – Component (substring) for a name to turn into a test name that is acceptable for e3-testsuite.

get_unique_test_name(test_name: str) str

Return a test name that is guaranteed to be unique.

Parameters:

test_name – Candidate test name. If the report index already has a test result with the same test name, this method generates another one based on it.

get_test_name(testsuite_name: str, testcase_name: str, classname: str | None = None) str

Combine xUnit testsuite/testcase names into a unique test name.

Parameters:
  • testsuite_name – Name associated with a xUnit <testsuite> element.

  • testcase_name – Name associated with a xUnit <testcase> element.

  • classname – If applicable, name of the class that owns this testcase.

e3.testsuite.report.xunit.read_xfails_from_yaml(filename: str) dict[str, str]

Read a XFAILs dict from a YAML file.

See the “xfails” parameter for XUnitImporter’s constructor for the expected YAML structure.

e3.testsuite.report.xunit.convert_main(argv: list[str] | None = None) None