Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/unit/test_plugin_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ def run_pytest(tmp_path, test_source, extra_args=None):
--json-report only accepts a plain filename (not a path). The plugin
writes the final JSON to <html-output>/<filename>, so the report lives at
tmp_path / HTML_OUTPUT / REPORT_FILENAME.

Args:
tmp_path: Temporary directory where test files and outputs are created.
test_source: Python source code for the test module to execute.
extra_args: Optional list of additional command-line arguments to pass
to pytest.
"""
test_file = tmp_path / "test_sample.py"
test_file.write_text(textwrap.dedent(test_source))
Expand Down Expand Up @@ -54,6 +60,15 @@ def pytest_configure(config):


def load_results(report_file):
"""Load test results from a JSON report file.

Args:
report_file: Path object pointing to the JSON report file.

Returns:
A list of test result dictionaries from the report's "results" field.
Returns an empty list if the field is missing.
"""
data = json.loads(report_file.read_text())
return data.get("results", [])

Expand Down
Loading