Esempio n. 1
0
 def __init__(
     self,
     ret: Union[int, ExitCode],
     outlines: Sequence[str],
     errlines: Sequence[str],
     duration: float,
 ) -> None:
     try:
         self.ret = pytest.ExitCode(ret)  # type: Union[int, ExitCode]
     except ValueError:
         self.ret = ret
     self.outlines = outlines
     self.errlines = errlines
     self.stdout = LineMatcher(outlines)
     self.stderr = LineMatcher(errlines)
     self.duration = duration
Esempio n. 2
0
    def pytest_sessionfinish(self, session, exitstatus):
        """
        Processes the results into a report.
        """
        exitcode = pytest.ExitCode(int(exitstatus))

        # at least one of the tests has failed
        if exitcode is pytest.ExitCode.TESTS_FAILED:
            self.results.fail()

        # an error has been encountered
        elif exitcode is not pytest.ExitCode.OK:
            message = None
            if self.last_err is not None:
                message = self.last_err
            else:
                message = f"Unexpected ExitCode.{exitcode.name}: check logs for details"
            self.results.error(message)

        for test in self.tests.values():
            self.results.add(test)