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.0.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.0.0
File Size Uploaded
partest_gen-1.0.0.tar.gz 68.5 kB Details

Built distribution (wheel)

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

Total release size: 150.1 kB

Release files / partest_gen-1.0.0.tar.gz

Download URL partest_gen-1.0.0.tar.gz
Size 68.5 kB
Tags Source
SHA-256 checksum
How to use checksums
68ca6436e66daca98bcb57c9c3c552c37a945a12d956b27ec31f69f2eef041bf
BLAKE2b-256 checksum
How to use checksums
d6b9a55b836877740a994fda883ff9924517b39c2af486ced0a4199d82567406
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.0.0-py3-none-any.whl

Download URL partest_gen-1.0.0-py3-none-any.whl
Size 81.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d4e40156fdd59df430bf642d5d62fb2d6563ddcda4b55d26074d6e54726dad2
BLAKE2b-256 checksum
How to use checksums
8030b5003faefbdfbf0fba20797054783921017fa274def6e3356244325bd122
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

1.1.0

2 release files

1.0.1

2 release files

This release

1.0.0 This release

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