Format and display a test result
(self, result: TestResult)
| 309 | self._format_result(result) |
| 310 | |
| 311 | def _format_result(self, result: TestResult) -> None: |
| 312 | """Format and display a test result""" |
| 313 | # Only show if verbose or important |
| 314 | if not (self.verbose or self._should_display(result)): |
| 315 | return |
| 316 | |
| 317 | # Format timestamp |
| 318 | delta = result.timestamp - self._start_time |
| 319 | |
| 320 | # Format message based on type |
| 321 | if result.type == TestResultType.SUCCESS: |
| 322 | color = "\033[92m" # Green |
| 323 | elif result.type == TestResultType.ERROR: |
| 324 | color = "\033[91m" # Red |
| 325 | elif result.type == TestResultType.WARNING: |
| 326 | color = "\033[93m" # Yellow |
| 327 | else: |
| 328 | color = "\033[0m" # Reset |
| 329 | |
| 330 | # Build message - only include timestamp, not command name |
| 331 | msg = f"{delta:.2f} " |
| 332 | msg += f"{color}{result.message}\033[0m" |
| 333 | |
| 334 | # Print with indentation |
| 335 | ts_print(f" {msg}") |
| 336 | |
| 337 | def _should_display(self, result: TestResult) -> bool: |
| 338 | """Determine if a result should be displayed""" |
no test coverage detected