pytest-json is a plugin for the pytest testing framework that generates JSON reports of test results. Last updated in January 2016, its latest version is 0.4.0. The project appears to be unmaintained, with limited Python and pytest version compatibility. It does not have an active release cadence.
pip install pytest-jsonVerified import paths — ran on the pinned version, not inferred.
To use `pytest-json`, create a test file (e.g., `test_example.py`). Then, run `pytest` from your terminal with the `--json` flag, specifying the desired output file. The plugin will generate a JSON report containing the test results. Custom environment data can be added via a `pytest` fixture in `conftest.py`.
Consider using 'pytest-json-report' (numirias/pytest-json-report) which is actively maintained and supports modern Python and pytest versions, or pin your Python and pytest versions to those supported by pytest-json if legacy compatibility is critical.
For advanced customization, consult the pytest changelog for changes to internal structures or consider using a more modern JSON reporting plugin that provides stable extension points.
Evaluate migrating to 'pytest-json-report' or another actively maintained pytest plugin that offers JSON reporting capabilities.
Ensure you are running `pytest` with the `--json` flag (e.g., `pytest --json=report.json`). If the error persists, it indicates an incompatibility with your `pytest` version. Downgrade `pytest` to a version compatible with `pytest-json` (e.g., `pytest<3.0` for Python 3.5, even older for Python 2.7).
Verify that all custom data added to the report is valid JSON, ensuring strings are double-quoted and complex Python objects are converted to their JSON-serializable equivalents (e.g., dictionaries, lists, strings, numbers, booleans, null).