{"library":"pytest-json","title":"pytest-json","description":"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.","language":"python","status":"abandoned","last_verified":"Thu Apr 16","install":{"commands":["pip install pytest-json"],"cli":null},"imports":["import pytest"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytest\nimport json\nimport os\n\n# Create a dummy test file for demonstration (test_example.py)\nwith open('test_example.py', 'w') as f:\n    f.write(\"\"\"\ndef test_success():\n    assert True\n\ndef test_failure():\n    assert False\n\"\"\")\n\n# Define the output report path\nreport_path = 'report.json'\n\n# Run pytest with the json report plugin\n# Ensure pytest-json is installed in the environment\n# The exit code can be non-zero if tests fail, so we capture it.\nexit_code = pytest.main([f'--json={report_path}', 'test_example.py'])\n\n# Check if the report was generated and read it\nif os.path.exists(report_path):\n    with open(report_path, 'r') as f:\n        report_data = json.load(f)\n    print(f\"JSON report generated successfully:\\n{json.dumps(report_data, indent=2)}\")\n    os.remove(report_path)\n    os.remove('test_example.py')\nelse:\n    print(\"JSON report was not generated.\")\n\n# Example of custom environment data (requires conftest.py)\n# conftest.py content:\n# @pytest.fixture(scope='session', autouse=True):\n# def extra_json_environment(request):\n#     request.config._json_environment.append(('CI_BUILD_ID', os.environ.get('CI_BUILD_ID', 'local')))\n","lang":"python","description":"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`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}