{"id":15102761,"url":"https://github.com/charbonnierg/pytest-broadcaster","last_synced_at":"2026-02-23T09:09:34.332Z","repository":{"id":231620433,"uuid":"782188790","full_name":"charbonnierg/pytest-broadcaster","owner":"charbonnierg","description":"Pytest plugin to broadcast pytest output to various destinations","archived":false,"fork":false,"pushed_at":"2025-03-02T02:20:05.000Z","size":2412,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T02:32:24.381Z","etag":null,"topics":["json-schema","pytest","pytest-plugin","python"],"latest_commit_sha":null,"homepage":"https://charbonnierg.github.io/pytest-broadcaster/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charbonnierg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-04T20:06:42.000Z","updated_at":"2025-03-02T02:19:16.000Z","dependencies_parsed_at":"2024-04-05T00:32:39.659Z","dependency_job_id":"68fa0c29-2adf-467c-9e9e-83e2417bde2c","html_url":"https://github.com/charbonnierg/pytest-broadcaster","commit_stats":{"total_commits":159,"total_committers":1,"mean_commits":159.0,"dds":0.0,"last_synced_commit":"e98456b2f6db7f99a034795f162ac0013a8001d7"},"previous_names":["charbonnierg/pytest-broadcaster"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charbonnierg%2Fpytest-broadcaster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charbonnierg%2Fpytest-broadcaster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charbonnierg%2Fpytest-broadcaster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charbonnierg%2Fpytest-broadcaster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charbonnierg","download_url":"https://codeload.github.com/charbonnierg/pytest-broadcaster/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332525,"owners_count":20921852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-schema","pytest","pytest-plugin","python"],"created_at":"2024-09-25T19:06:10.898Z","updated_at":"2025-10-30T20:39:08.451Z","avatar_url":"https://github.com/charbonnierg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytest-broadcaster)](https://pypi.org/project/pytest-broadcaster)\n[![GitHub deployments](https://img.shields.io/github/deployments/charbonnierg/pytest-broadcaster/github-pages?label=documentation\u0026link=https%3A%2F%2Fcharbonnierg.github.io%2Fpytest-broadcaster)](https://charbonnierg.github.io/pytest-broadcaster)\n\n# pytest-broadcaster\n\nA plugin to write pytest collect output to various destinations.\n\nAvailable destinations:\n\n- JSON file\n- JSON lines file.\n- HTTP URL (only POST request)\n\nAdditional destinations can be added in the future, and users can also implement their own destinations.\n\n## Project state\n\nThis project is in early development. The plugin is functional, but the API is not stable yet. The plugin is tested with Python 3.8, 3.9, 3.10, 3.11, and 3.12.\n\nIf you find a bug, please open an issue. Contributions are welcome.\n\n## Install\n\n```bash\npip install pytest-broadcaster\n```\n\n## Motivation\n\nIf you ever wanter to build a tool that needs to parse the output of `pytest --collect-only`, you may have noticed that the output is not very easy to parse. This plugin aims to provide a more structured output that can be easily parsed by other tools.\n\nHistorically, this project only parsed the output of `pytest --collect-only`, but it has been extended to parse the output of `pytest` in general.\n\nJSON schemas are provided for clients to help them parse the output of the plugin.\n\n## Usage\n\n- Use the `--collect-report` to generate a JSON file:\n\n```bash\npytest --collect-report=collect.json\n```\n\n- Use the `--collect-log` to generate a JSON lines file:\n\n```bash\npytest --collect-log=collect.jsonl\n```\n\n- Use the `--collect-url` to send session result to an HTTP URL:\n\n```bash\npytest --collect-url=http://localhost:8000/collect\n```\n\n- Use the `--collect-log-url` to send each session event to an HTTP URL:\n\n```bash\npytest --collect-log-url=http://localhost:8000/collect\n```\n\n## JSON Schemas\n\nThe plugin provides JSON schemas to validate the output of the plugin. Generated schemas are located in the [schemas](./schemas/) directory, while the original schemas are located in the [src/pytest_broadcaster/schemas](./src/pytest_broadcaster/schemas) directory.\n\n### `SessionResult`\n\nThe JSON output produced by the plugin follows the [SessionResult JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/session_result.json).\n\nPython tools can also use the [`SessionResult` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/session_result.py) to parse the JSON file.\n\n\n### `SessionEvent`\n\nThe JSON lines output produced by the plugin follows the [SessionEvent JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/session_event.json).\n\nThis schema is the union of the different events that can be emitted by the plugin:\n\n- [`SessionStart` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/session_start.json)\n- [`WarningMessage` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/warning_message.json)\n- [`ErrorMessage` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/error_message.json)\n- [`CollectReport` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/collect_report.json)\n- [`TestCaseSetup` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/test_case_setup.json)\n- [`TestCaseCall` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/test_case_call.json)\n- [`TestCaseTeardown` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/test_case_teardown.json)\n- [`TestCaseEnd` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/test_case_end.json)\n- [`SessionEnd` JSON Schema](https://github.com/charbonnierg/pytest-broadcaster/tree/main/schemas/session_end.json)\n\nPython tools can also use the [`SessionEvent` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/session_event.py) to parse the JSON lines file, as well as the differnt event classes:\n\n- [`SessionStart` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/session_start.py)\n- [`WarningMessage` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/warning_message.py)\n- [`ErrorMessage` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/error_message.py)\n- [`CollectReport` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/collect_report.py)\n- [`TestCaseSetup` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/test_case_setup.py)\n- [`TestCaseCall` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/test_case_call.py)\n- [`TestCaseTeardown` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/test_case_teardown.py)\n- [`TestCaseEnd` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/test_case_end.py)\n- [`SessionEnd` dataclass](https://github.com/charbonnierg/pytest-broadcaster/tree/main/src/pytest_broadcaster/models/session_end.py)\n\n## Hooks\n\n### `pytest_broadcaster_add_destination`\n\nThe plugin provides a hook that can be used by users to add custom destinations. For example, in your `conftest.py` you can add the following code to write the collect output to a JSON file and a JSON lines file:\n\n```python\nfrom pytest_broadcaster import JSONFile, JSONLinesFile\n\n\ndef pytest_broadcaster_add_destination(add):\n    add(JSONFile(\"collect.json\"))\n    add(JSONLinesFile(\"collect.jsonl\"))\n```\n\n### `pytest_broadcaster_set_reporter`\n\nThe plugin provides a hook that can be used by users to set a custom reporter. For example, in your `conftest.py` you can add the following code to use a custom reporter (well the default reporter in this case):\n\n```python\nfrom pytest_broadcaster import DefaultReporter\n\n\ndef pytest_broadcaster_set_reporter(set):\n    set(DefaultReporter())\n```\n\n## Alternatives\n\n- [pytest-json-report](https://github.com/numirias/pytest-json-report): This plugin predates `pytest-broadcaster`, has been used by several organizations, and works well. However, there is no JSON schema to validate the output, nor JSON lines output. Also, it does not allow adding custom destinations as `pytest-broadcaster` does.\n\n- [pytest-report-log](https://github.com/pytest-dev/pytest-reportlog): This package provides both JSON and JSON lines output, but it does not provide a JSON schema to validate the output. Also, it does not allow adding custom destinations as `pytest-broadcaster` does.\n\n## Credits\n\n- [pytest](https://docs.pytest.org/en/8.0.x/): Well, this is a pytest plugin.\n- [pytest-report-log](https://github.com/pytest-dev/pytest-reportlog): This package was heavily inspired by the `report-log` plugin.\n- [pytest-json-report](https://github.com/numirias/pytest-json-report): The `pytest-json-report` plugin was also a source of inspiration.\n- [pytest-csv](https://github.com/nicoulaj/pytest-csv): The `pytest-csv` plugin was also a source of inspiration.\n- [`datamodel-code-generator`](https://github.com/koxudaxi/datamodel-code-generator): The dataclasses generation from JSON schemas is performed using `datamodel-code-generator`.\n- [rye](https://rye-up.com/): Project management is easy thanks to `rye`. It is also used to lint and format the code.\n- [hatch-vcs](https://github.com/ofek/hatch-vcs): Python project version control is easy thanks to `hatch-vcs`.\n- [pyright](https://github.com/microsoft/pyright): `pyright` is used to check the code and find bugs sooner.\n\n## License\n\nThis project is licensed under the terms of the MIT license. See [LICENSE](./LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharbonnierg%2Fpytest-broadcaster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharbonnierg%2Fpytest-broadcaster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharbonnierg%2Fpytest-broadcaster/lists"}