Exemple #1
0
def parse_xml(xmlpath: Path) -> (str, float, float):
    """
    Load junit files from xmlpath, then parse them for point values and return
    simplified output.
    """
    xml = JUnitXml.fromfile(str(
        xmlpath.absolute() / "TEST-junit-vintage.xml")) + JUnitXml.fromfile(
            str(xmlpath.absolute() / "TEST-junit-jupiter.xml"))
    earned_points = 0
    total_points = 0
    output = ""

    for suite in xml:
        for case in suite:
            point_str = points_regex.search(case.system_out)
            point_val = float(point_str.groups()[0])
            point_out = ""
            if point_str:
                # add point attribute to case, then determine value of test
                case.points = FloatAttr("points")
                total_points += point_val
                if case.result is None:
                    case.points = point_val
                    earned_points += point_val
                else:
                    case.points = 0
                point_out = f"{case.points:1g} points"
Exemple #2
0
 def test_attr(self):
     TestCase.text = Attr("text")
     TestCase.int = IntAttr("int")
     TestCase.float = FloatAttr("float")
     element = TestCase("foo")
     element.text = "foo"
     element.int = 10
     element.float = 8.5
     self.assertEqual(element.text, "foo")
     self.assertEqual(element.int, 10)
     self.assertEqual(element.float, 8.5)