partest-gen
Turn an OpenAPI document into a runnable pytest suite: endpoints, payloads, validations, collection facades, and the priority-one test matrix that partest's coverage methodology asks each operation for.
pip install partest-gen
partest comes with it — the generated suite runs on that harness. Python 3.10+.
One command
partest-gen from-openapi ./my-suite --file openapi.yaml --depth p1 --with-ui
cd my-suite && pytest src/api/tests --collect-only -q
A green collect means every emitted module imports and every case is discovered. That is the acceptance test for a generation; the rest of the work is writing the assertions.
What you get
my-suite/
├── requirements/{base,api,ui,local}.txt
├── confpartest.py, conftest.py, env.example, pytest.ini
├── .partest/{suite_ir.json, openapi_summary.md}
└── src/
├── api/
│ ├── resources/{endpoints,payloads,validations,collections,rbac,security}
│ └── tests/{conftest, test_zorro, <tag>/…}
└── ui/ # with --with-ui: pages, fixtures, baselines, tests
- Classified operations. Each endpoint gets a method subtype, and the subtype decides
which test cases it needs. The classification comes from
partest.methodology, so the generator and the coverage report never disagree about what an endpoint is. - Stubs with the right shape. Every emitted call carries an explicit
type=and lands in the correct cell of the coverage matrix. Most are skipped with aTODO— a generated assertion that passes on any response would raise the coverage number without testing anything. - Facades instead of strings.
models.<tag>.paths.*,.payload.*(),.validate.*— regenerated with the specification, so they cannot drift away from it. - A per-tag checklist.
P1_CHECKLIST.mdand.partest/openapi_summary.mdmap every required case to its stub; both are regenerated on sync, and progress is read from the coverage report. - An isolated UI tree.
src/uinever loads OpenAPI or the API coverage session.
Commands
partest-gen from-openapi ./suite --file openapi.yaml --depth p1 # or --url
partest-gen sync-openapi ./suite --depth p1 # the spec changed
partest-gen init-ui ./suite # add the UI tree later
partest-gen dump-ir openapi.yaml -o suite_ir.json # inspect, write nothing
partest-gen --version
--depth |
Emits |
|---|---|
resources |
paths + collection facades |
default |
+ payloads, validations, Default and NotAllowed tests |
p1 |
+ the full priority-one stub set, plus a checklist per tag |
Your files stay yours
Files the generator owns carry AUTO-GENERATED by partest-gen. sync-openapi rewrites those,
plus skeleton placeholders nobody has edited; anything else is left alone unless you pass
--force — including per-tag checklists from older releases, which invited hand marks.
Generated files whose operation left the specification are listed after a sync, and deleted
only with --prune.
So do not hand-edit a banner file — the edit survives until the next sync and then vanishes. Put your code in a sibling module and import it.
Documentation
Source and issues: https://github.com/Dec01/partest-gen
The user-facing pages also ship inside the package, so they are readable in the terminal where you are actually running the tool:
python -m partest_gen.docs list # what is available
python -m partest_gen.docs show howto-scaffold # read a page
python -m partest_gen.docs path # where the files live
Included: the first run end to end, turning stubs into tests, re-syncing after the spec changes, the contract of generated code, the parts of the generator, and the UI layer.
Requirements
Python 3.10+, partest>=2.1.0, pyyaml, requests (only for --url). The generated UI tree
additionally needs pip install 'partest[ui]' and a Playwright browser.
License
MIT.
Metadata
Release files for partest-gen 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| partest_gen-1.2.1.tar.gz | 103.8 kB | Without provenance | Details for partest_gen-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| partest_gen-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for partest_gen-1.2.1-py3-none-any.whl |
Total release size: 211.1 kB
Release files / partest_gen-1.2.1.tar.gz
| Download URL | partest_gen-1.2.1.tar.gz |
|---|---|
| Size | 103.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6d5219823118eb4457a31a9897982ef838b50314749bf3dda39a46dedd8c265
|
|
BLAKE2b-256 checksum How to use checksums |
7cc12507304205a77bb3a3a9f406eaae5c7fdcfa512557ba1ba79046c4770ec8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / partest_gen-1.2.1-py3-none-any.whl
| Download URL | partest_gen-1.2.1-py3-none-any.whl |
|---|---|
| Size | 107.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a06ef2059e24c2d10ec04cc7f55c79dcc07c9a2f0a761073e04d5ad5ee243b9d
|
|
BLAKE2b-256 checksum How to use checksums |
14625ff4a97070a9b075ccced6db96539ea7bc26ee9d80949a18980146b5dbdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for partest-gen 1.2.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.