Skip to main content

CTRF for pytest

Pytest implementation of Common Test Report Format (CTRF) for test results.
Test report will be generated in JSON format.
Test report can be used to prettify the report in GitHub Actions with github-actions-ctrf.
Do not worry if report in GitHub does not appear immediately. It takes some time to process the report.

Features

  • Generates JSON report
  • Tested to work correctly with and without pytest-xdist
  • Tested to get browser name from pytest-playwright
  • Parametrized tests are supported and reported as 1 test with multiple retries

Installation

pip install pytest-json-ctrf

Usage

generate report.json file in the root directory of the project. File path is mandatory

pytest --ctrf report.json

Environment Variables may be used to specify the required Environment Object fields when using the CTRF slack-test-reporter.

CTRF_BUILD_NAME="Pytest JSON CTRF Report"
CTRF_BUILD_NUMBER="000"
CTRF_BUILD_URL="https://ctrf.io]"

JSON example

More info here: https://ctrf.io/docs/schema/examples

{
  "reportFormat": "CTRF",
  "specVersion": "0.0.0",
  "generatedBy": "pytest",  
  "results": {
    "tool": {
      "name": "jest"
    },
    "summary": {
      "tests": 3,
      "passed": 1,
      "failed": 1,
      "pending": 0,
      "skipped": 1,
      "other": 0,
      "start": 1706644023,
      "stop": 1706644043
    },
    "environment": {
        "buildName": "Pytest JSON CTRF Report",
        "buildNumber": "000",
        "buildUrl": "https://ctrf.io"
    },
    "tests": [
      {
        "name": "User should be able to login",
        "status": "passed",
        "duration": 1200
      },
      {
        "name": "User profile information should be correct",
        "status": "failed",
        "duration": 800
      },
      {
        "name": "User should be able to logout",
        "status": "skipped",
        "duration": 0
      }
    ]
  }
}

Report Example

Example Image

Technical details

For future me and others who are interested in the technical details of the implementation.
The main idea is to handle xdist plugin because without it collecting report is quite straightforward.
By the example of putest-json-report plugin, I have learned that different plugins can be registered for the controller and workers node.
The pytest_runtest_logreport hook in the controller node is used to collect the test results from all the nodes so other nodes can just add some details to the TestReport object.

Credits

Changelog

  • 0.5.3 - fixed issue 6 - @pytest.mark.parametrize will no longer be added to tags to prevent exhausting memory
  • 0.5.1 - added mandatory root object fields: reportFormat, specVersion, generatedBy
  • 0.5.0 - Changed logic of handling parametrized tests. Previously they were marked as retries, now they are reported as separate tests
  • 0.4.1 - Introduced backward compatibility with python 3.8, fixed issues with the time formats

Roadmap

  • Add screenshots handling
  • Add hooks for the report extension

Release files for pytest-json-ctrf 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-json-ctrf 0.5.3
File Size Uploaded
pytest_json_ctrf-0.5.3.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-json-ctrf 0.5.3
File Interpreter ABI Platform
pytest_json_ctrf-0.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / pytest_json_ctrf-0.5.3.tar.gz

Download URL pytest_json_ctrf-0.5.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
485494504390f382a86ee3d86ffa9b2f55c81223809dca0cc04963c60c3a6466
BLAKE2b-256 checksum
How to use checksums
f3ff88adcc4a9a9772b330b31c1556c7bf41adc951b1fe6ae6a1ed0241e731ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Release files / pytest_json_ctrf-0.5.3-py3-none-any.whl

Download URL pytest_json_ctrf-0.5.3-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27565a1da62ed98e91ffe90b3d6a038b8376822e073a21b3c224344bd9cf4799
BLAKE2b-256 checksum
How to use checksums
6f6558c0a5d3114481dea2d339800607be588750b4b9abaedbf79d92a8877e7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.3 This release

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.1

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page