Skip to content

Enhance HTML report generation with test results - #1

Open
FinSecTech wants to merge 6 commits into
nireshs:mainfrom
FinSecTech:main
Open

FinSecTech wants to merge 6 commits into
nireshs:mainfrom
FinSecTech:main

Conversation

@FinSecTech

Copy link
Copy Markdown

pytest_terminal_summary now falls back to terminalreporter.stats when _test_results is empty, rebuilding results from the terminal reporter's aggregated data (which xdist does populate). Also added a discard for the unused exitstatus parameter.

`pytest_terminal_summary` now falls back to `terminalreporter.stats` when `_test_results` is empty, rebuilding results from the terminal reporter's aggregated data (which xdist does populate). Also added a discard for the unused `exitstatus` parameter.
…fore. Some bugs have been fixed.

   - `HTMLGeneratorDashboard.__init__()` now accepts a `parallel_execution="No"` keyword arg and stores it.
   - `generate_test_configuration_section()` now renders `{self.parallel_execution}` instead of hardcoded `"No"`.
   - `enhance_html_report_dashboard()` passes the kwarg through to the constructor.
- `error_reporter.get_error_info(test_id)` does not exist. The method is called `get_test_errors(test_id)`. Fix: Changed to `error_reporter.get_test_errors(test_id)`.

After running tests with `-n=4`, the report will display `Parallel Execution: 4 workers` instead of `No`.
…fore. Some bugs have been fixed.

- In `pytest_terminal_summary`, the code now reads `config.option.numprocesses` (the attribute set by pytest-xdist's `-n` flag). If it's set and > 0, it sends "N workers" to the HTML generator; otherwise "No".

- When xdist runs tests in worker processes, the controller's `EnhancedErrorReporter` is empty because `pytest_runtest_makereport` (which captures error data) only runs in workers. The "View Error" popups showed nothing useful.
Fix: After rebuilding `test_results` from `terminalreporter.stats`, inject error details from the deserialized `TestReport.longrepr` into the controller's `EnhancedErrorReporter`.

- `pytest_sessionfinish` checks `if _history_tracker and _test_results:`, but with xdist, `_test_results` is empty in the controller (only populated in workers). So no history was ever saved for xdist runs.
Fix: After rebuilding `test_results` from `terminalreporter.stats`, save the run to the history database directly from `pytest_terminal_summary`. History, flaky test detection, and trend data now work with xdist.
Injected screenshots into the dashboard's data pipeline. Modified the dashboard's HTML generator to display them.
Injected screenshots into the dashboard's data pipeline. Modified the dashboard's HTML generator to display them.
@nireshs

nireshs commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@FinSecTech Thanks for your contribution. Please check above 15 errors from pre-commit validation. kindle fix those and send me updated pull request to merge.

File "/home/runner/work/pytest-html-dashboard/pytest-html-dashboard/src/pytest_html_dashboard/init.py", line 12, in
from .error_reporting import ErrorClassifier, ErrorDetails
File "/home/runner/work/pytest-html-dashboard/pytest-html-dashboard/src/pytest_html_dashboard/error_reporting.py", line 442
html += f"{icon} {category}{count}{
^
SyntaxError: unterminated string literal (detected at line 442)
Error: Process completed with exit code 1.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants