{"id":937,"library":"pytest-json-ctrf","title":"Pytest JSON CTRF Reporter","description":"pytest-json-ctrf is a pytest plugin that generates test reports in the Common Test Report Format (CTRF) as a JSON file. This standard format allows for consistent reporting across various testing tools and frameworks, facilitating better analysis and integration with external systems like GitHub Actions for prettifying reports. The current version is 0.3.6, with releases tied to pytest compatibility and feature enhancements.","status":"active","version":"0.3.6","language":"python","source_language":"en","source_url":"https://github.com/infopulse/pytest-common-test-report-json","tags":["pytest","testing","reporting","json","ctrf","plugin"],"install":[{"cmd":"pip install pytest-json-ctrf","lang":"bash","label":"Install plugin"}],"dependencies":[{"reason":"Core testing framework for which this is a plugin.","package":"pytest"}],"imports":[],"quickstart":{"code":"import pytest\n\n# tests/test_example.py\ndef test_passing_example():\n    assert True\n\ndef test_failing_example():\n    assert False\n\n# To run and generate report:\n# pytest --ctrf report.json\n# cat report.json","lang":"python","description":"First, create a simple test file (e.g., `test_example.py`). Then, run pytest from your terminal, specifying the `--ctrf` flag followed by the desired output filename. This will generate a JSON report in the Common Test Report Format in the specified file."},"warnings":[{"fix":"Always use `pytest --ctrf <your_report_file_name.json>`.","message":"The `--ctrf` command-line option requires a file path argument. If not provided, pytest will not generate the CTRF report, or may raise an error depending on the pytest version. Ensure a valid file path is always specified.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the plugin is installed (`pip install pytest-json-ctrf`) and activate it using the `--ctrf` command-line flag when running pytest. No explicit Python imports are typically needed in your test files for this plugin.","message":"As a pytest plugin, `pytest-json-ctrf` is activated via a command-line option (`--ctrf`) rather than direct Python imports within your test code. Attempting to import symbols directly from `pytest_json_ctrf` in your tests is generally unnecessary and will likely result in an `ImportError` or other unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Rename test files and functions to follow pytest conventions (e.g., `test_my_feature.py`, `def test_functionality()`).","message":"To ensure your tests are discovered and reported correctly by pytest (and subsequently by `pytest-json-ctrf`), adhere to pytest's standard test discovery rules: test files should start with `test_` or end with `_test.py`, and test functions/methods should start with `test_`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-03-29T00:00:00.000Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Ensure the plugin is installed by running `pip install pytest-json-ctrf` in the active Python environment. If already installed, verify the environment's `PATH` or virtual environment activation.","cause":"This error indicates that the `pytest-json-ctrf` plugin is either not installed or not accessible in the current Python environment where pytest is being executed, preventing pytest from recognizing its command-line option.","error":"pytest: error: unrecognized arguments: --json-ctrf=report.json"},{"fix":"Verify that your pytest tests are actually running and producing reportable outcomes; an empty file often indicates no tests were executed or reported, or a prior error prevented report generation.","cause":"This error occurs when attempting to parse the generated CTRF report file (e.g., `report.json`), but the file is empty or contains malformed, non-JSON content.","error":"json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"},{"fix":"Confirm the `pytest --json-ctrf=report.json` command was executed successfully without errors, and check the current working directory or specified path to ensure the `report.json` file exists in the expected location after the test run.","cause":"This error occurs when a subsequent command or script tries to access the CTRF report file, but it was either not generated, or not created in the expected directory.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'report.json'"},{"fix":"Change the output directory to a location where the user has write permissions (e.g., the current working directory or a user-specific temporary directory), or adjust the file system permissions for the target directory.","cause":"Pytest-json-ctrf is attempting to create or write the report file in a directory where the running user or process does not have sufficient write permissions.","error":"PermissionError: [Errno 13] Permission denied: 'report.json'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}