Skip to main content

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 a TODO — 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.md and .partest/openapi_summary.md map every required case to its stub; both are regenerated on sync, and progress is read from the coverage report.
  • An isolated UI tree. src/ui never 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.2

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

Source distribution (sdist)

Source distribution for partest-gen 1.2.2
File Size Uploaded Provenance Actions
partest_gen-1.2.2.tar.gz 112.0 kB Without provenance Details for partest_gen-1.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for partest-gen 1.2.2
File Interpreter ABI Platform Actions
partest_gen-1.2.2-py3-none-any.whl Python 3 none any Details for partest_gen-1.2.2-py3-none-any.whl

Total release size: 224.9 kB

Release files / partest_gen-1.2.2.tar.gz

Download URL partest_gen-1.2.2.tar.gz
Size 112.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fa150aac01a9c594f8c628d7c5729d3bdd2aa9b9e6cc53cc8f35a23a603c6b8d
BLAKE2b-256 checksum
How to use checksums
943aee721bc37fac0b1edb393a693ac54ca79502efde89956cc1942d6759a60f
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.2-py3-none-any.whl

Download URL partest_gen-1.2.2-py3-none-any.whl
Size 112.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0644f0afa12735c6712b304f23c97cad6e4596dcd396363540341a3551088354
BLAKE2b-256 checksum
How to use checksums
5edb73ff8abaf03c31f5f96b607a4f68a88aad1fcc737c1e89b0d9d38603813c
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.2

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.

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