Reads the content of the junit-results file produced by pytest and returns imported data.

def import_junit(junit_file, **kwargs):
    """Reads the content of the junit-results file produced by pytest and returns imported data."""
    xml_root = _get_xml_root(junit_file)

    results = []
    for test_data in xml_root:
        if test_data.tag != "testcase":
            continue

        verdict, comment, properties = _parse_testcase_record(test_data)
        properties, parameters = _extract_parameters_from_properties(properties)

        title = test_data.get("name")
        classname = test_data.get("classname")
        time = test_data.get("time", 0)
        filepath = test_data.get("file")

        data = [
            ("title", title),
            ("classname", classname),
            ("verdict", verdict),
            ("comment", comment),
            ("time", time),
            ("file", filepath),
        ]
        for key in sorted(properties):
            data.append((key, properties[key]))
        if parameters:
            data.append(("params", OrderedDict(parameters)))

        results.append(OrderedDict(data))

    return xunit_exporter.ImportedData(results=results, testrun=None)