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

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.1
File Size Uploaded
partest_gen-1.0.1.tar.gz 69.6 kB Details

Built distribution (wheel)

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

Total release size: 151.2 kB

Release files / partest_gen-1.0.1.tar.gz

Download URL partest_gen-1.0.1.tar.gz
Size 69.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ac1ee7054588befe956ba478401d243c8f4bbda700cbccc09a59b0cc38629b8d
BLAKE2b-256 checksum
How to use checksums
0d8f843047e1859ec6301b0e9d621ffca99fc3d331c93faa078ec7ce4c07c547
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.1-py3-none-any.whl

Download URL partest_gen-1.0.1-py3-none-any.whl
Size 81.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77af64d933099b8179356c9d9380a4a9cb0dae98baa1103c0ab65306160224a6
BLAKE2b-256 checksum
How to use checksums
d63ebc6bfc844b946c47d74742658d47e7b40d5696e8b6ead4066df9c54f6272
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

This release

1.0.1 This release

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