def pytest_terminal_summary(terminalreporter: TerminalReporter, exitstatus: int, config: Config) -> None: """Show factoryboy random state when there are test failures or errors. Factoryboy uses randomness in order to generate its values which is great for fuzzing but makes it really hard to reproduce tests which fail due to a fuzzed value. This hook outputs the random state used by factory-boy (and faker) when there are test failures (or errors). The outputted state is an ascii, base64 encoded pickle dump. Args: terminalreporter (TerminalReporter): Add output to the pytest output. exitstatus (int): The exit status of pytest (unused) config (Config): The pytest config (unused) """ show_state = config.getoption("show_state") or ( os.environ.get("SHOW_FACTORYBOY_STATE") == "True") failures: list[BaseReport] = terminalreporter.getreports("failed") errors: list[BaseReport] = terminalreporter.getreports("error") if show_state and (failures or errors): terminalreporter.write_sep("=", "factory-boy random state") encoded_state = base64.b64encode( pickle.dumps(factory.random.get_random_state())) terminalreporter.write_line(encoded_state.decode("ascii"))
def pytest_terminal_summary(self, terminalreporter: TerminalReporter) -> None: functions = self.infra_manager.get_squashed(self.environment) terminalreporter.write_sep("-", "pytest-infrastructure results") terminalreporter.write_line(f"{repr(self._resolve_meta_data())}") if not functions: terminalreporter.write_line( "no pytest-infrastructure functions collected & executed.") else: for function in functions: terminalreporter.write_line(repr(function))
def pytest_terminal_summary(terminalreporter: TerminalReporter) -> None: if terminalreporter.config.option.pastebin != "failed": return if "failed" in terminalreporter.stats: terminalreporter.write_sep("=", "Sending information to Paste Service") for rep in terminalreporter.stats["failed"]: try: msg = rep.longrepr.reprtraceback.reprentries[-1].reprfileloc except AttributeError: msg = terminalreporter._getfailureheadline(rep) file = StringIO() tw = create_terminal_writer(terminalreporter.config, file) rep.toterminal(tw) s = file.getvalue() assert len(s) pastebinurl = create_new_paste(s) terminalreporter.write_line(f"{msg} --> {pastebinurl}")
def pytest_terminal_summary(self, terminalreporter: TerminalReporter, exitstatus: ExitCode, config: Config) -> None: if self.exception: terminalreporter.ensure_newline() terminalreporter.section('Jira XRAY', sep='-', red=True, bold=True) terminalreporter.write_line( 'Could not publish results to Jira XRAY!') if self.exception.message: terminalreporter.write_line(self.exception.message) else: if self.issue_id and self.logfile: terminalreporter.write_sep( '-', f'Generated XRAY execution report file: {Path(self.logfile).absolute()}' ) elif self.issue_id: terminalreporter.write_sep( '-', f'Uploaded results to JIRA XRAY. Test Execution Id: {self.issue_id}' )
def pytest_terminal_summary(terminalreporter: TerminalReporter, exitstatus: int, config: Config) -> None: """Create the custom report. In the directory that contains the report generator, the report database is created and the report generator is called. """ # path to the report generator reporter_path = config.getoption("report_generator") if reporter_path is None: return if not terminalreporter.stats: # no test have been run thus no report to create or update return output_root = Path(config.getoption("output_root")) terminalreporter.write_sep("=", "starting report generation") try: report.generate(reporter_path, output_root, terminalreporter) except Exception as e: terminalreporter.write_line(str(e), red=True) terminalreporter.write_sep("=", "report generation failed", red=True) else: terminalreporter.write_sep("=", "report generation done")
def pytest_terminal_summary(self, terminalreporter: TerminalReporter) -> None: terminalreporter.write_sep("-", "generated xml file: {}".format(self.logfile))