pubtest
The Gherkin steps every Sustenaut suite shares. One grammar, GRAMMAR.md, shipped two ways:
pubtest, a Python package: a pytest-bdd plugin that loads into every pytest session.@sustenaut/pubtest, an npm package: the same steps for cucumber-js and quickpickle.
A suite writes the Givens of its own domain and its own When. Everything a scenario checks, and the setups that repeat across repositories (files, the environment, programs and stand-ins for them, HTTP, fake services, recorded answers, secrets, git), are pubtest's, in the same words everywhere. The same features run against both packages, under pytest-bdd, cucumber-js and quickpickle, so a step means the same in Python and in Node.
Python
pubrules's managed tests/requirements-pubrules.txt pins pubtest for every
repository, so a suite only writes steps:
from pytest_bdd import parsers, scenarios, when
scenarios("planner.feature")
@when(parsers.parse('the planner plans "{week}"'))
def plans(ctx, week):
ctx.attempt(lambda: planner.plan(week))
Scenario: A week with no work is refused
Given a scratch directory
When the planner plans "2026-W53"
Then it is refused, saying "no such week"
Besides the steps, the plugin gives a suite ctx (the scenario's context:
attempt, cleanup, the result), binary(name) (a program under test from
<NAME>_BIN_DIR, never PATH), run(...), a marker for every @tag in the
feature files, and Hypothesis's examples per property from PUBRULES_FUZZ_RUNS.
A suite that tests a service gives pubtest its client:
import pubtest.http
@pytest.fixture
def http_client():
return pubtest.http.asgi(create_app()) # or .wsgi(app), or .url("http://127.0.0.1:8000")
Node
npm install --save-dev --save-exact github:Sustenaut/pubtest#v0.1.0
// features/support/steps.js, for cucumber-js
import * as cucumber from "@cucumber/cucumber";
import { register } from "@sustenaut/pubtest";
import { fromFetch } from "@sustenaut/pubtest/http";
import worker from "../../src/worker.js";
register(cucumber, { client: () => fromFetch((request) => worker.fetch(request, env)) });
cucumber.When("the planner plans {string}", function (week) {
return this.attempt(() => planner.plan(week));
});
For quickpickle, pass its module and { runner: "quickpickle" }, and load the
file through vitest's setupFiles.
Record and replay
A suite that calls outside services through integrations' Caller replays
what they answered: one cassette per scenario, recorded with
pubtest record, in the data repository beside the repository
(../<repo>-data/integrations/cassettes/). Turn it on in pubrules.json:
"pubtest": {"cassettes": true}
and install integrations beside pubtest: the suite's own pin of it in Python,
@sustenaut/integrations (an optional peer) in Node. pubtest itself never
depends on integrations, whose own suite runs on pubtest. Then:
pubtest record --all # record every scenario's calls
pubtest record --changed # only those whose cassette is out of date
and the failure steps (Given the "github" integration can't be reached)
break a scenario's calls on purpose, over its cassette. GRAMMAR.md, "Record
and replay", has the modes, variables, paths, errors and test customers.
Developing
make venv && npm ci --ignore-scripts
make functional # the features under pytest-bdd, with coverage
npm test # the same features under cucumber-js, then quickpickle
features/ is the library's own suite, the steps a suite would write are in
tests/conftest.py and test/suite.js (the same texts in both), and
tests/python-features/ holds the Python-only adapter scenarios. The suite
turns cassettes on, kept in tests/cassettes/, and its example test customer
is in tests/customers/ and test/customer.js; pubtest record --all
records them again, through a stand-in for the network. A change to
a step changes GRAMMAR.md, both packages and a feature, in one pull request,
and records itself with pubrel add. Releases are cut with pubrel prepare
from a checkout whose corpus/.publet holds the release key.
Licence
Apache-2.0.
Metadata
Release files for pubtestrules 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pubtestrules-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for pubtestrules-0.4.0-py3-none-any.whl |
Release files / pubtestrules-0.4.0-py3-none-any.whl
| Download URL | pubtestrules-0.4.0-py3-none-any.whl |
|---|---|
| Size | 50.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f08bd47ffd00780af0aadd21b588608e357d335c931e00f5f184dfbbd2c9143
|
|
BLAKE2b-256 checksum How to use checksums |
96b6255e4a7afe71b307b8cc64df922d0c14f00e73e6c5a7319d400b7e255938
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logSecurity for pubtestrules 0.4.0
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.
Full provenance
1 file in this release has been uploaded with provenance metadata.
Attestation for pubtestrules-0.4.0-py3-none-any.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logA 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.