Skip to content
Novus Examples
json6.3 KB

pytest — JSON Report (pytest-json-report)

The pytest-json-report document, which records setup, call and teardown as three separate phases per test and keeps error distinct from failed in its summary. A test can pass its call phase and still error in teardown, which is why summing outcomes without reading the phases gives the wrong total. Reports the same canonical run as the JUnit dialect files: 12 tests, 9 passed, 1 assertion failure, 1 error and 1 skip.

Preview — first 50 linesjson
{
  "created": 1786000469.481,
  "duration": 7.45,
  "exitcode": 1,
  "root": "/builds/novus/checkout",
  "environment": {
    "Python": "3.12.4",
    "Platform": "Linux-6.8.0-x86_64",
    "Packages": {
      "pytest": "8.2.2",
      "pluggy": "1.5.0"
    }
  },
  "summary": {
    "passed": 9,
    "failed": 1,
    "error": 1,
    "skipped": 1,
    "total": 12,
    "collected": 12
  },
  "tests": [
    {
      "nodeid": "tests/cart/test_pricingtest.py::test_applies_unit_price",
      "lineno": 18,
      "keywords": [
        "cart"
      ],
      "outcome": "passed",
      "setup": {
        "duration": 0.0009,
        "outcome": "passed"
      },
      "call": {
        "duration": 0.643,
        "outcome": "passed"
      },
      "teardown": {
        "duration": 0.0004,
        "outcome": "passed"
      }
    },
    {
      "nodeid": "tests/cart/test_pricingtest.py::test_applies_quantity_multiplier",
      "lineno": 25,
      "keywords": [
        "cart"
      ],
      "outcome": "passed",
      "setup": {
278 lines total — download for the full file.

Specifications

Seed
61200
Encoding
UTF-8
Line Endings
LF
Format
pytest-json-report
Total
12
Passed
9
Failed
1
Error
1
Skipped
1
Phases
setup, call, teardown
Keeps Error Separate
true

Testing contract

Expected to pass
Scenario
Determine each test's outcome from its setup, call and teardown phases.
Expected result
12 tests are reported with summary passed=9, failed=1, error=1, skipped=1, and every test's outcome matches its call-phase outcome.

What is a .json file?

JSON (JavaScript Object Notation) is a lightweight, text-based data-interchange format representing objects, arrays, strings, numbers, booleans, and null. It is language-independent, human-readable, and the dominant format for web APIs and configuration. It requires a single well-formed root value.

How to use this file

Use an example JSON file to test parsers and serializers, schema validation, Unicode and number-precision handling, and API request or response processing.

How to use this file for testing

“pytest — JSON Report (pytest-json-report)” is a deterministic Novus Examples fixture for JSON parsing, Conversion testing, Error handling. Flat, deeply nested, JSON Lines, and intentionally invalid JSON for testing parsers and error handling.

Documented properties for this file: seed 61200 · UTF-8 · LF. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Test and coverage reports document their totals (suites, cases, passes, failures, skips, covered lines) in the spec table. Point your CI dashboard, coverage gate, or report converter at the file and assert those counts survive; format twins carry identical numbers so a conversion can be scored exactly.

Feed the file to your parser and assert it handles the documented quirks — quoted delimiters, embedded newlines, ragged rows, or invalid syntax; the valid↔invalid distinction is labelled in the title.

Code examples

import json

with open("pytest-json-report.json") as f:
    data = json.load(f)
print(type(data), len(data))

Generated by generation/testing.py. Free for any use, no attribution required — license.