sontris-xunit2pdf 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. sontris_xunit2pdf-0.1.1/.forgejo/workflows/release_build.yml +115 -0
  2. sontris_xunit2pdf-0.1.1/.gitignore +16 -0
  3. sontris_xunit2pdf-0.1.1/.readthedocs.yaml +14 -0
  4. sontris_xunit2pdf-0.1.1/AGENTS.md +141 -0
  5. sontris_xunit2pdf-0.1.1/PKG-INFO +331 -0
  6. sontris_xunit2pdf-0.1.1/README.md +322 -0
  7. sontris_xunit2pdf-0.1.1/docs/api.rst +48 -0
  8. sontris_xunit2pdf-0.1.1/docs/conf.py +52 -0
  9. sontris_xunit2pdf-0.1.1/docs/developer-guide/architecture.md +79 -0
  10. sontris_xunit2pdf-0.1.1/docs/developer-guide/contributing.md +52 -0
  11. sontris_xunit2pdf-0.1.1/docs/developer-guide/setup-and-workflow.md +78 -0
  12. sontris_xunit2pdf-0.1.1/docs/getting-started.md +108 -0
  13. sontris_xunit2pdf-0.1.1/docs/index.md +74 -0
  14. sontris_xunit2pdf-0.1.1/docs/prompt-continue-with-real-junit-export.md +51 -0
  15. sontris_xunit2pdf-0.1.1/docs/requirements.txt +5 -0
  16. sontris_xunit2pdf-0.1.1/docs/tester-guide.md +100 -0
  17. sontris_xunit2pdf-0.1.1/docs/troubleshooting.md +86 -0
  18. sontris_xunit2pdf-0.1.1/docs/tutorial-testing-with-real-junit-data.md +132 -0
  19. sontris_xunit2pdf-0.1.1/docs/tutorials/multi-run-demo.md +85 -0
  20. sontris_xunit2pdf-0.1.1/docs/user-guide/automation.md +86 -0
  21. sontris_xunit2pdf-0.1.1/docs/user-guide/input-and-runs.md +101 -0
  22. sontris_xunit2pdf-0.1.1/docs/user-guide/metadata-and-parameters.md +100 -0
  23. sontris_xunit2pdf-0.1.1/docs/user-guide/report-and-config.md +96 -0
  24. sontris_xunit2pdf-0.1.1/docs/user-guide/requirements.md +85 -0
  25. sontris_xunit2pdf-0.1.1/pyproject.toml +68 -0
  26. sontris_xunit2pdf-0.1.1/run.py +633 -0
  27. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/__init__.py +10 -0
  28. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/__main__.py +5 -0
  29. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/aggregation.py +314 -0
  30. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/cli.py +83 -0
  31. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/config.py +89 -0
  32. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/models.py +63 -0
  33. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/parser.py +242 -0
  34. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/pdf.py +1717 -0
  35. sontris_xunit2pdf-0.1.1/src/sontris/testing/xunit2pdf/requirements.py +314 -0
  36. sontris_xunit2pdf-0.1.1/tests/fixtures/multi_run/2.7.1/pytest-2026-11-30T10-00-00Z.xml +50 -0
  37. sontris_xunit2pdf-0.1.1/tests/fixtures/multi_run/2.7.1/pytest-2026-11-30T11-00-00Z.xml +36 -0
  38. sontris_xunit2pdf-0.1.1/tests/fixtures/multi_run/2.7.1/pytest-2026-11-30T12-00-00Z.xml +139 -0
  39. sontris_xunit2pdf-0.1.1/tests/fixtures/multi_run/2.7.1/requirements.json +46 -0
  40. sontris_xunit2pdf-0.1.1/tests/fixtures/representative_pytest_report.xml +126 -0
  41. sontris_xunit2pdf-0.1.1/tests/fixtures/requirements.json +35 -0
  42. sontris_xunit2pdf-0.1.1/tests/test_aggregation.py +407 -0
  43. sontris_xunit2pdf-0.1.1/tests/test_config_and_pdf.py +506 -0
  44. sontris_xunit2pdf-0.1.1/tests/test_parser.py +127 -0
  45. sontris_xunit2pdf-0.1.1/tests/test_requirements.py +149 -0
  46. sontris_xunit2pdf-0.1.1/tests/test_versioning.py +110 -0
  47. sontris_xunit2pdf-0.1.1/uv.lock +858 -0
@@ -0,0 +1,115 @@
1
+ name: CI and Release
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ workflow_dispatch:
7
+ inputs:
8
+ release_tag:
9
+ description: Version tag to publish from the protected main branch
10
+ required: true
11
+ type: string
12
+
13
+ jobs:
14
+ quality:
15
+ name: Lint, typecheck, test, docs, and build
16
+ runs-on: ubuntu-22.04
17
+ timeout-minutes: 20
18
+ steps:
19
+ - name: Check out repository
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v5
26
+ with:
27
+ enable-cache: true
28
+ cache-dependency-glob: |
29
+ uv.lock
30
+ docs/requirements.txt
31
+
32
+ - name: Install locked project dependencies
33
+ run: uv sync --locked
34
+
35
+ - name: Check lockfile
36
+ run: uv run --locked run.py lock check
37
+
38
+ - name: Lint and format check
39
+ run: uv run --locked run.py precheck lint
40
+
41
+ - name: Type check
42
+ run: uv run --locked run.py precheck typecheck
43
+
44
+ - name: Test with coverage
45
+ run: uv run --locked run.py test unit
46
+
47
+ - name: Build Sphinx documentation
48
+ run: uv run --locked run.py docs
49
+
50
+ - name: Build distributions
51
+ run: uv run --locked run.py build
52
+
53
+ release:
54
+ name: Publish package and create Forgejo release
55
+ if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
56
+ needs: quality
57
+ runs-on: ubuntu-22.04
58
+ timeout-minutes: 20
59
+ steps:
60
+ - name: Check out repository history
61
+ uses: actions/checkout@v4
62
+ with:
63
+ fetch-depth: 0
64
+
65
+ - name: Install uv
66
+ uses: astral-sh/setup-uv@v5
67
+ with:
68
+ enable-cache: true
69
+ cache-dependency-glob: uv.lock
70
+
71
+ - name: Install task runner dependencies
72
+ run: uv sync --locked
73
+
74
+ - name: Verify release tag and check out tagged commit
75
+ env:
76
+ RELEASE_TAG: ${{ inputs.release_tag }}
77
+ run: uv run --locked run.py checkout-release --tag "$RELEASE_TAG"
78
+
79
+ - name: Install dependencies for the release tag
80
+ run: uv sync --locked
81
+
82
+ - name: Build, verify, and publish release
83
+ env:
84
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
85
+ FORGEJO_API_URL: ${{ github.api_url }}
86
+ FORGEJO_REPOSITORY: ${{ github.repository }}
87
+ FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
88
+ RELEASE_TAG: ${{ inputs.release_tag }}
89
+ run: uv run --locked run.py release --tag "$RELEASE_TAG"
90
+
91
+ deploy-docs:
92
+ name: Trigger Read the Docs build
93
+ if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
94
+ needs: release
95
+ runs-on: ubuntu-22.04
96
+ timeout-minutes: 5
97
+ steps:
98
+ - name: Check out repository
99
+ uses: actions/checkout@v4
100
+
101
+ - name: Install uv
102
+ uses: astral-sh/setup-uv@v5
103
+ with:
104
+ enable-cache: true
105
+ cache-dependency-glob: |
106
+ uv.lock
107
+ docs/requirements.txt
108
+
109
+ - name: Install locked task runner dependencies
110
+ run: uv sync --locked
111
+
112
+ - name: Trigger Read the Docs build
113
+ env:
114
+ READTHEDOCS_API_TOKEN: ${{ secrets.READTHEDOCS_API_TOKEN }}
115
+ run: uv run --locked run.py trigger-docs
@@ -0,0 +1,16 @@
1
+ .venv/
2
+ __pycache__/
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ .mypy_cache/
6
+ .ty_cache/
7
+ .coverage
8
+ htmlcov/
9
+ *.py[cod]
10
+ build/
11
+ dist/
12
+ *.egg-info/
13
+ real-junit-report.pdf
14
+ requirements-coverage-demo.pdf
15
+ /reports/
16
+ /docs/_build/
@@ -0,0 +1,14 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-24.04
5
+ tools:
6
+ python: "3.12"
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+ fail_on_warning: true
11
+
12
+ python:
13
+ install:
14
+ - requirements: docs/requirements.txt
@@ -0,0 +1,141 @@
1
+ # Project Guidelines
2
+
3
+ ## Product scope and behavior
4
+
5
+ - `xunit2pdf` is a standalone Python 3.11+ tool for converting JUnit XML into
6
+ configurable PDF reports. Its PyPI distribution is `sontris-xunit2pdf`, its
7
+ installed command is `xunit2pdf`, and its package namespace is
8
+ `sontris.testing.xunit2pdf`.
9
+ - Keep XML parsing, report models, aggregation, configuration, requirements
10
+ analysis, PDF rendering, and repository task tooling separate. Before adding
11
+ functionality, inspect and reuse existing implementations where their
12
+ contracts fit. Prefer small, direct changes; apply KISS/DRY and avoid
13
+ unrelated cleanup.
14
+ - Preserve unknown valid XML attributes, properties, direct elements,
15
+ namespaces, nested metadata, and source XML. Do not impose a project-specific
16
+ fixed schema or silently discard data just because the renderer does not
17
+ understand it.
18
+ - Derive verdicts from testcase result elements with precedence `ERROR`,
19
+ `FAIL`, `SKIP`, `PASS`. Count each testcase once, including under nested
20
+ suites.
21
+ - A directory input represents runs for one software version and includes its
22
+ direct `*.xml` files. Latest matching executions replace earlier results;
23
+ cases absent from later subset runs remain. Parameterized combinations must
24
+ remain distinct even when their logical testcase name and stable ID match.
25
+ Run ordering uses XML run timestamps, then filename timestamps, then file
26
+ modification time as a warned fallback. A testcase `time` is duration, not
27
+ its run timestamp.
28
+ - Keep testcase names readable. Represent variants with stable parameter
29
+ properties/IDs and display their actual parameter configuration in the
30
+ report; do not encode arbitrarily long parameter sets in the testcase name.
31
+ - Every testcase detail section starts on a new PDF page. Long testcase
32
+ details may continue on following pages, but the next testcase must start
33
+ fresh. Preserve readable wrapped text, repeated table headers, and colored
34
+ verdicts.
35
+ - CLI output filenames are hints: generated PDFs always go under `./reports/`
36
+ with a unique timestamped name. Keep `reports/` and other generated output,
37
+ caches, virtual environments, and distributions out of version control.
38
+ - Requirement catalog URLs must be absolute HTTP(S) links. Use reserved,
39
+ illustrative `.example.test` URLs in fixtures and documentation, not real
40
+ internal or customer-system links.
41
+
42
+ ## Data safety and privacy
43
+
44
+ - The checked-in JUnit examples are synthetic; this repository does not contain
45
+ an approved real company export. Treat XML, requirements catalogs, and PDFs
46
+ as potentially sensitive because they may include usernames, internal paths,
47
+ test inputs, URLs, failure output, or tracebacks.
48
+ - Keep real exports outside version control. For regression coverage, use a
49
+ small sanitized fixture that preserves only the structure and values needed
50
+ to reproduce the behavior. Do not add a real customer/internal export or
51
+ requirement link without explicit approval.
52
+ - Never commit, print, or expose credentials, tokens, private keys, or other
53
+ secrets. Keep deployment tokens in the platform's secret store and do not
54
+ include secrets in logs, examples, fixtures, or generated reports.
55
+ - Do not run package publishing, release, or Read the Docs deployment commands
56
+ as ordinary validation. These cause external side effects and require
57
+ explicit authorization.
58
+
59
+ ## Code quality and dependencies
60
+
61
+ - Use Python type hints and concise Google-style docstrings consistent with
62
+ neighboring code. Keep public behavior and its documentation aligned.
63
+ - Preserve existing behavior outside the request. Fix only issues introduced
64
+ by or tightly coupled to the change.
65
+ - Whenever work reveals project-specific guidance or restrictions that are
66
+ missing or stale, update this `AGENTS.md` in the same change unless the user
67
+ explicitly asks not to. Keep the guidance concise, accurate, and specific to
68
+ this repository.
69
+ - Add focused tests for new or changed behavior, especially XML edge cases,
70
+ latest-run matching, parameter identity, requirements links, and PDF page
71
+ layout. Do not weaken the coverage scope to improve a reported percentage;
72
+ the current unit-test coverage is about 91%.
73
+ - Keep runtime dependencies limited to those required by the generator.
74
+ Runtime/development dependencies belong in `pyproject.toml` and `uv.lock`.
75
+ Documentation-only dependencies belong in `docs/requirements.txt` and
76
+ should not be added to runtime dependencies.
77
+ - When changing dependency declarations, regenerate and review `uv.lock`, then
78
+ check it. Review registry/source changes before retaining them.
79
+ - Use argument lists for subprocess commands; do not interpolate untrusted
80
+ filenames or values into shell command strings.
81
+
82
+ ## Development and validation
83
+
84
+ - Use `uv` for environment management and run project tasks through `uv run`.
85
+ `uv run --locked run.py --help` is the source of truth for available tasks.
86
+ - Install the project environment with `uv sync --locked`. For Python changes,
87
+ run the relevant focused test and, before completion, the project's quality
88
+ checks:
89
+
90
+ ```shell
91
+ uv run --locked run.py lock check
92
+ uv run --locked run.py precheck lint
93
+ uv run --locked run.py precheck typecheck
94
+ uv run --locked run.py test unit
95
+ uv run --locked run.py build
96
+ ```
97
+
98
+ - `uv run --locked run.py test collect` checks test discovery. A local
99
+ real-export smoke test can be enabled with
100
+ `XUNIT2PDF_TEST_XML=/path/to/file-or-folder uv run --locked run.py test unit`.
101
+ Keep that input outside version control and inspect the resulting PDF under
102
+ `./reports/`.
103
+ - Generate a report with
104
+ `uv run --locked run.py run INPUT OUTPUT [--requirements FILE] [--config FILE]`.
105
+ The output path is printed by the CLI and is under `./reports/`, not
106
+ necessarily the directory implied by `OUTPUT`.
107
+ - Never run `run.py release`, `run.py publish`, or `run.py trigger-docs` as part
108
+ of routine validation. They publish packages or trigger external services.
109
+
110
+ ## Documentation and Read the Docs
111
+
112
+ - Keep user/developer-facing documentation in English and update the README
113
+ and relevant Sphinx pages when commands, behavior, or configuration change.
114
+ The documentation includes user, developer, tester, tutorial, and API
115
+ material.
116
+ - Build documentation changes with
117
+ `uv run --locked run.py docs`. The command installs
118
+ `docs/requirements.txt` ephemerally and treats Sphinx warnings as errors.
119
+ Generated HTML is under `docs/_build/html/en/`.
120
+ - Keep `.readthedocs.yaml`, `docs/conf.py`, and `docs/requirements.txt`
121
+ consistent. The Read the Docs project slug is `sontris-xunit2pdf`.
122
+ - `.forgejo/workflows/release_build.yml` builds docs in normal quality
123
+ validation and triggers the Read the Docs `latest` build only after a
124
+ successful manual release dispatch from `main`. The deploy job requires the
125
+ Forgejo Actions secret `READTHEDOCS_API_TOKEN`; never add its value to the
126
+ repository or invoke deployment without authorization.
127
+
128
+ ## Release workflow
129
+
130
+ - The Forgejo workflow is `.forgejo/workflows/release_build.yml`. Ordinary
131
+ pushes and pull requests run quality checks, tests, documentation build, and
132
+ package build; they do not publish or deploy documentation.
133
+ - A release is an explicit manual workflow dispatch from protected `main`.
134
+ Preserve tag verification and required credentials. Do not run release
135
+ validation against a live publishing token or create a release unless asked.
136
+ - Package versions are generated from Git tags using `uv-dynamic-versioning`.
137
+ `run.py tag` derives the release tag from a built development wheel; verify
138
+ the version in wheel metadata rather than reading a static project version.
139
+ - Keep README instructions, the manual release workflow, package/release
140
+ scripts, and Read the Docs deployment setup consistent when modifying this
141
+ lifecycle.
@@ -0,0 +1,331 @@
1
+ Metadata-Version: 2.4
2
+ Name: sontris-xunit2pdf
3
+ Version: 0.1.1
4
+ Summary: Generate configurable PDF reports from JUnit XML test results.
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: pyyaml>=6.0
7
+ Requires-Dist: reportlab>=4.0
8
+ Description-Content-Type: text/markdown
9
+
10
+ # xunit2pdf
11
+
12
+ `xunit2pdf` converts Pytest/JUnit XML test results into a portrait PDF report
13
+ with a cover page, verdict statistics, a page-numbered contents section, and
14
+ individual detail pages for each testcase. It is designed to run locally or in
15
+ a CI/CD pipeline. Its Python package namespace is
16
+ `sontris.testing.xunit2pdf`. The PyPI distribution is
17
+ `sontris-xunit2pdf`; the installed CLI command remains `xunit2pdf`.
18
+
19
+ The [user, developer, and tester documentation](docs/index.md) includes setup
20
+ guides, tutorials, CI examples, API reference, and troubleshooting.
21
+ Documentation is also published at
22
+ [sontris-xunit2pdf.readthedocs.io](https://sontris-xunit2pdf.readthedocs.io/).
23
+
24
+ ## Install and run
25
+
26
+ ```shell
27
+ uv sync --locked
28
+ uv run --locked run.py run report.xml report.pdf \
29
+ --requirements requirements.json --config report.yml
30
+ ```
31
+
32
+ The output argument supplies a filename hint. Every CLI-generated PDF is written
33
+ to `./reports/` in the current working directory, with a timestamp and unique
34
+ suffix in its name (for example, `reports/report-20261130-212459-a1b2c3d4.pdf`).
35
+ The CLI logs the exact output path. The `reports/` folder is git-ignored.
36
+
37
+ For a software-version folder containing multiple JUnit XML runs, pass the
38
+ folder instead of one file:
39
+
40
+ ```shell
41
+ uv run --locked run.py run reports/2.7.1 report-2.7.1.pdf \
42
+ --requirements requirements.json
43
+ ```
44
+
45
+ The report combines all direct `*.xml` files in the folder. For each testcase
46
+ execution identity, the latest result replaces earlier runs; distinct
47
+ parameterized inputs remain separate. Run order comes from a JUnit root/suite
48
+ timestamp when present, otherwise a timestamp in the filename, then file
49
+ modification time as a fallback. Explicit testcase execution timestamps take
50
+ precedence for that testcase. The JUnit `testcase time` attribute is duration,
51
+ not a run timestamp.
52
+
53
+ The checked-in example contains three runs for version `2.7.1`, including
54
+ retests, all four verdicts, a 2-by-3 parameter matrix, custom and namespaced XML
55
+ metadata, output streams, requirement gaps, an unknown requirement ID, and a
56
+ testcase without a requirement reference:
57
+
58
+ ```shell
59
+ uv run --locked run.py run tests/fixtures/multi_run/2.7.1 \
60
+ /tmp/xunit2pdf-multi-run-example.pdf \
61
+ --requirements tests/fixtures/multi_run/2.7.1/requirements.json
62
+ ```
63
+
64
+ The CLI uses the supplied output basename but writes a uniquely named PDF under
65
+ `./reports/`. The XML files and catalog are in
66
+ [tests/fixtures/multi_run/2.7.1](tests/fixtures/multi_run/2.7.1).
67
+
68
+ Identity uses a testcase ID property such as `TCID` together with the testcase
69
+ name/class/file; without such an ID it falls back to suite/name/class/file.
70
+ `parameter_id` or the parameter properties distinguish parameterized variants.
71
+ Case-level timestamp attributes/properties such as `executed_at` or
72
+ `execution_timestamp` are used when present. Testcases found only in earlier
73
+ runs remain in the combined report.
74
+
75
+ The installed console command and namespaced Python module entry point are also
76
+ available:
77
+
78
+ ```shell
79
+ uv run --locked xunit2pdf report.xml report.pdf \
80
+ --requirements requirements.json --config report.yml
81
+ uv run --locked xunit2pdf reports/2.7.1 report-2.7.1.pdf \
82
+ --requirements requirements.json
83
+ uv run --locked python -m sontris.testing.xunit2pdf report.xml report.pdf \
84
+ --requirements requirements.json
85
+ ```
86
+
87
+ ## Development and release tasks
88
+
89
+ `run.py` is the project task facade. See its commands and options with:
90
+
91
+ ```shell
92
+ uv run --locked run.py --help
93
+ ```
94
+
95
+ Common local validation commands:
96
+
97
+ ```shell
98
+ uv run --locked run.py lock check
99
+ uv run --locked run.py precheck lint
100
+ uv run --locked run.py precheck typecheck
101
+ uv run --locked run.py test unit
102
+ uv run --locked run.py test collect
103
+ uv run --locked run.py docs
104
+ uv run --locked run.py build
105
+ ```
106
+
107
+ The documentation command builds warning-free Sphinx HTML under
108
+ `docs/_build/html/en/`. Its dependencies are isolated in
109
+ `docs/requirements.txt`.
110
+
111
+ `uv run --locked run.py tag` builds a wheel to resolve the current Git-derived
112
+ development version, then creates the corresponding release tag from a clean
113
+ working tree. Push the tag and check it out before release:
114
+
115
+ ```shell
116
+ uv run --locked run.py tag
117
+ git push origin <version-tag>
118
+ uv run --locked run.py checkout-release --tag <version-tag>
119
+ uv sync --locked
120
+ uv run --locked run.py release --tag <version-tag>
121
+ ```
122
+
123
+ The version comes from the latest Git tag and commit distance; a tagged commit
124
+ builds as that release version, while later commits build as a PEP 440
125
+ development version. The package metadata is the source of truth for builds
126
+ and documentation.
127
+
128
+ To publish the built wheel and source distribution to PyPI, set
129
+ `UV_PUBLISH_TOKEN` in the environment and run:
130
+
131
+ ```shell
132
+ uv run --locked run.py publish
133
+ ```
134
+
135
+ The release command requires a clean checkout, a tag reachable from
136
+ `origin/main`, and `UV_PUBLISH_TOKEN`, `FORGEJO_API_URL`,
137
+ `FORGEJO_REPOSITORY`, and `FORGEJO_TOKEN`. It builds and validates the package,
138
+ publishes it to PyPI, then creates the Forgejo release. The Forgejo workflow
139
+ runs lint, type checks, tests, a Sphinx documentation build, and a package
140
+ build on pushes and pull requests. The workflow is
141
+ `.forgejo/workflows/release_build.yml`. A manual dispatch from `main` runs the
142
+ release flow; after it succeeds, a separate job triggers the Read the Docs
143
+ `latest` build for project slug `sontris-xunit2pdf`. Configure the Forgejo
144
+ Actions secret `READTHEDOCS_API_TOKEN` with a Read the Docs account token that
145
+ can access that project. The token must be present before dispatching a
146
+ release; a missing or unauthorized token fails the docs deployment job.
147
+
148
+ The direct installation option remains available without the development task
149
+ runner:
150
+
151
+ ```shell
152
+ python -m pip install .
153
+ xunit2pdf report.xml report.pdf --requirements requirements.json --config report.yml
154
+ ```
155
+
156
+ To install the published package from PyPI, use its distribution name:
157
+
158
+ ```shell
159
+ python -m pip install sontris-xunit2pdf
160
+ ```
161
+
162
+ Or invoke the package as a module:
163
+
164
+ ```shell
165
+ python -m sontris.testing.xunit2pdf report.xml report.pdf \
166
+ --requirements requirements.json
167
+ ```
168
+
169
+ The CLI returns status `0` on success and `2` for an input, configuration, or
170
+ output error. Logs go to stderr. Use `--log-level DEBUG` for diagnostic output.
171
+
172
+ ## XML assumptions and metadata
173
+
174
+ There is no actual project JUnit export in this repository; the included
175
+ annotated XML fixture is synthetic. The parser accepts the conventional
176
+ `testsuites`/`testsuite`/`testcase` hierarchy, including nested suites, and
177
+ identifies results from actual `error`, `failure`, and `skipped` child elements
178
+ in that precedence order. A testcase without any of these elements is
179
+ considered passing. Testcases are counted once regardless of the number of
180
+ containing suite levels.
181
+
182
+ Standard testcase attributes include `name`, `classname`, `file`, `line`,
183
+ `time`, and `assertions`. Testcase properties are stored under
184
+ `metadata.properties`; other attributes go to `metadata.attributes`.
185
+ Non-standard direct testcase elements—including valid XML annotation tags such
186
+ as `<precondition>` and `<TCID>`—are retained in `metadata.elements`, their text
187
+ is indexed under `metadata.custom`, and the original serialized XML is retained
188
+ for each. Each testcase also retains its complete serialized XML as
189
+ `metadata.source_xml`. Namespaced names are preserved in Clark notation (for example
190
+ `{urn:example}TCID`). Values from nested `properties/property` elements are
191
+ indexed by their `name` and repeated property names remain lists.
192
+
193
+ Suite-level and root-level properties are preserved as report metadata.
194
+ Testcase runtime totals are the sum of each testcase duration, avoiding double
195
+ counting suite totals from nested suites. The pass rate is passed testcases
196
+ divided by all testcases; an empty report has a 0% pass rate.
197
+
198
+ ## YAML configuration
199
+
200
+ All settings are optional. Use `cover_fields` for report metadata and `columns`
201
+ to prioritize fields near the top of each testcase detail table:
202
+
203
+ ```yaml
204
+ project_title: Example Project
205
+ report_title: Automated Test Report
206
+ logo: assets/project-logo.png
207
+ missing_value: "Not provided"
208
+ cover_fields:
209
+ - label: Test Run ID
210
+ path: properties.test_run_id
211
+ - label: Test Environment
212
+ path: properties.environment
213
+ - label: Version
214
+ path: properties.software_version
215
+ columns:
216
+ - label: Testcase
217
+ path: name
218
+ - label: Verdict
219
+ path: verdict
220
+ - label: Test ID
221
+ path: metadata.properties.TCID
222
+ - label: Preconditions
223
+ path: metadata.custom.preconditions
224
+ - label: Duration (s)
225
+ path: duration
226
+ - label: Failure Message
227
+ path: message
228
+ ```
229
+
230
+ Cover paths address report-level properties directly (or use
231
+ `attributes.<name>` for root XML attributes). Configured table paths can address
232
+ testcase fields such as `classname`, `file`, `line`, `duration`, and
233
+ `assertions`, result fields such as `message`, `traceback`, `system_out`, and
234
+ `system_err`, or `metadata.*` values. All unconfigured testcase fields,
235
+ properties, attributes, and custom XML are still included below them. A
236
+ namespaced custom element can be selected using its expanded name in the path,
237
+ such as `metadata.custom.{urn:example}TCID`.
238
+
239
+ The portrait PDF keeps major sections together: the coverage dashboard,
240
+ requirement mapping, coverage gaps, test summary, report metadata, contents, and
241
+ each testcase start on separate pages. Mapping and detail tables repeat their
242
+ headers and continue across pages when necessary. Each testcase page contains
243
+ the verdict, testcase file, standard result fields, every property, custom
244
+ metadata, unknown-element XML, and the complete serialized testcase XML.
245
+ List-valued testcase properties—including `requirements`—are shown one item
246
+ per line inside a single table cell, including when selected as a configured
247
+ column.
248
+
249
+ ## Requirements coverage
250
+
251
+ Pass the requirements catalog with `--requirements requirements.json` to add a
252
+ coverage analysis immediately after the cover. The JSON file can be a list of
253
+ requirement IDs or objects, or an object containing a `requirements` list.
254
+ Objects accept `id` (also `requirement_id`, `requirementId`, `key`, or `code`),
255
+ `title`, `name`, `summary`, `requirement`, or `text` for the label,
256
+ `description`, and additional descriptive fields. An optional `url` (also
257
+ `link`, `href`, `web_url`, or `web_uri`) can point directly to the requirement in
258
+ Jama, Xray, or another tool; it must be an absolute HTTP(S) URL. The requirement
259
+ ID in the mapping table links to that external item, while testcase references
260
+ continue to link internally to the mapping row. For example:
261
+
262
+ ```json
263
+ {
264
+ "requirements": [
265
+ {
266
+ "id": "AUTH-REQ-01",
267
+ "title": "Authenticate valid users",
268
+ "description": "Users with valid credentials can access the application.",
269
+ "url": "https://jira.example.test/browse/AUTH-REQ-01"
270
+ }
271
+ ]
272
+ }
273
+ ```
274
+
275
+ The `.example.test` URL in the fixture is illustrative; replace it with each
276
+ requirement's real Jama/Xray item URL in your catalog.
277
+
278
+ Testcase XML can link one or more requirements through a JUnit property named
279
+ `requirements`, for example
280
+ `<property name="requirements" value="AUTH-REQ-01,AUTH-REQ-02"/>`. Repeated
281
+ properties, comma/semicolon/pipe/whitespace-delimited values, JSON-array values,
282
+ and a direct custom `<requirements>` element are supported. Common singular
283
+ aliases such as `RequirementID` are also recognized.
284
+ When the matching requirement exists in the JSON catalog, its ID in the
285
+ testcase detail table is an internal PDF link to that requirement's mapping row.
286
+ IDs not found in the catalog remain plain text and are reported as unmatched.
287
+
288
+ For a `pytest.mark.parametrize` test, keep one `<testcase>` element per
289
+ parameterized execution while retaining the same testcase `name` and `TCID`.
290
+ Add a unique `parameter_id` and one `parameter_<argument>` property per input
291
+ value. For example, two executions of `test_normalize_username` can use the
292
+ same testcase name and ID while setting `parameter_id` to `trim_whitespace` or
293
+ `lowercase_email`; add a `parameter_<argument>` property for each input argument
294
+ as well. The PDF keeps the logical testcase name and ID unchanged, adds a
295
+ compact execution ID such as `test_normalize_username/P01`, and uses concise
296
+ parameter values such as `input=alice, mode=trim` in the contents and requirement
297
+ mapping instead of generic variant numbers. Each detail page also places a
298
+ complete parameter-configuration table before the testcase metadata table.
299
+ Full values remain in that table even when long headings are shortened. The
300
+ XML fixture demonstrates multiple parameter properties.
301
+
302
+ The front-matter analysis includes catalog coverage, testcase-to-requirement
303
+ mapping, uncovered requirements, testcases without requirement references, and
304
+ references missing from the catalog. Donut charts show requirement coverage
305
+ and testcase linkage; a verdict chart shows the worst linked testcase status
306
+ per requirement. The test-results section also includes overall verdict
307
+ distribution and per-suite stacked verdict bars. The fixture
308
+ `tests/fixtures/requirements.json` and the annotated JUnit XML fixture
309
+ demonstrate the input format from files, including repeated parameterized
310
+ testcases.
311
+
312
+ ## XML fixture for parser checks
313
+
314
+ `tests/fixtures/representative_pytest_report.xml` is a standalone, synthetic
315
+ pytest-style export with nested suites, run metadata, all four verdicts,
316
+ properties, output streams, and custom testcase elements such as `<TCID>` and
317
+ `<preconditions>`. Parser and PDF tests read this file from disk rather than
318
+ embedding all XML in Python strings. Replace it with, or add alongside it, a
319
+ real export to validate project-specific XML before configuring its fields.
320
+
321
+ To smoke-test a real export without editing the fixture or test code:
322
+
323
+ ```shell
324
+ XUNIT2PDF_TEST_XML=/path/to/real-junit-report.xml uv run --locked run.py test unit
325
+ ```
326
+
327
+ That optional test parses the supplied file and renders it with the default PDF
328
+ configuration; without the environment variable, only that smoke test is skipped.
329
+ See the [real-data tutorial](docs/tutorial-testing-with-real-junit-data.md) for
330
+ the full workflow and [continuation prompt](docs/prompt-continue-with-real-junit-export.md)
331
+ to resume this work with a real export.