| 33 | |
| 34 | |
| 35 | class RunAndParse: |
| 36 | def __init__(self, pytester: Pytester, schema: xmlschema.XMLSchema) -> None: |
| 37 | self.pytester = pytester |
| 38 | self.schema = schema |
| 39 | |
| 40 | def __call__( |
| 41 | self, *args: Union[str, "os.PathLike[str]"], family: Optional[str] = "xunit1" |
| 42 | ) -> Tuple[RunResult, "DomNode"]: |
| 43 | if family: |
| 44 | args = ("-o", "junit_family=" + family) + args |
| 45 | xml_path = self.pytester.path.joinpath("junit.xml") |
| 46 | result = self.pytester.runpytest("--junitxml=%s" % xml_path, *args) |
| 47 | if family == "xunit2": |
| 48 | with xml_path.open() as f: |
| 49 | self.schema.validate(f) |
| 50 | xmldoc = minidom.parse(str(xml_path)) |
| 51 | return result, DomNode(xmldoc) |
| 52 | |
| 53 | |
| 54 | @pytest.fixture |
no outgoing calls