(
self, session: Session, exitstatus: int | ExitCode
)
| 956 | |
| 957 | @hookimpl(wrapper=True) |
| 958 | def pytest_sessionfinish( |
| 959 | self, session: Session, exitstatus: int | ExitCode |
| 960 | ) -> Generator[None]: |
| 961 | result = yield |
| 962 | self._tw.line("") |
| 963 | summary_exit_codes = ( |
| 964 | ExitCode.OK, |
| 965 | ExitCode.TESTS_FAILED, |
| 966 | ExitCode.INTERRUPTED, |
| 967 | ExitCode.USAGE_ERROR, |
| 968 | ExitCode.NO_TESTS_COLLECTED, |
| 969 | ExitCode.MAX_WARNINGS_ERROR, |
| 970 | ) |
| 971 | if exitstatus in summary_exit_codes and not self.no_summary: |
| 972 | self.config.hook.pytest_terminal_summary( |
| 973 | terminalreporter=self, exitstatus=exitstatus, config=self.config |
| 974 | ) |
| 975 | # Check --max-warnings threshold after all warnings have been collected. |
| 976 | max_warnings = self._get_max_warnings() |
| 977 | if max_warnings is not None and session.exitstatus == ExitCode.OK: |
| 978 | warning_count = len(self.stats.get("warnings", [])) |
| 979 | if warning_count > max_warnings: |
| 980 | session.exitstatus = ExitCode.MAX_WARNINGS_ERROR |
| 981 | self.write_line( |
| 982 | "Tests pass, but maximum allowed warnings exceeded: " |
| 983 | f"{warning_count} > {max_warnings}", |
| 984 | red=True, |
| 985 | ) |
| 986 | if session.shouldfail: |
| 987 | self.write_sep("!", str(session.shouldfail), red=True) |
| 988 | if exitstatus == ExitCode.INTERRUPTED: |
| 989 | self._report_keyboardinterrupt() |
| 990 | self._keyboardinterrupt_memo = None |
| 991 | elif session.shouldstop: |
| 992 | self.write_sep("!", str(session.shouldstop), red=True) |
| 993 | self.summary_stats() |
| 994 | return result |
| 995 | |
| 996 | @hookimpl(wrapper=True) |
| 997 | def pytest_terminal_summary(self) -> Generator[None]: |
nothing calls this directly
no test coverage detected