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 are the backlog.
  • 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 start with AUTO-GENERATED by partest-gen. sync-openapi rewrites those and nothing else; files without the banner are left alone unless you pass --force.

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.0.0, pyyaml, requests (only for --url). The generated UI tree additionally needs pip install 'partest[ui]' and a Playwright browser.

License

MIT.

Release files for partest-gen 1.1.0

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.1.0
File Size Uploaded
partest_gen-1.1.0.tar.gz 72.0 kB Details

Built distribution (wheel)

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

Total release size: 154.0 kB

Release files / partest_gen-1.1.0.tar.gz

Download URL partest_gen-1.1.0.tar.gz
Size 72.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cc6d7e984b762c834122de04aa877fdcf21e42cde8a08b3cb7b832f2e496f49c
BLAKE2b-256 checksum
How to use checksums
a547968a07e7b422baddd20b999d36a5b7edcc852d93955f5a77702cdffeb314
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.1.0-py3-none-any.whl

Download URL partest_gen-1.1.0-py3-none-any.whl
Size 82.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba7c8688218feb17e19b628dc0d2ecc897bc6c7837237a504034304e7890bfc9
BLAKE2b-256 checksum
How to use checksums
d1f90f4c63564258ebbf09a0d27c96b0846d540375bccb55d411fb48595f2e83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.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