kensho-pytest
A pytest plugin that emits the canonical Kensho v1 JSON format.
Run your tests, then point the kensho CLI at kensho-results/ to get a
self-contained static HTML report.
Install
pip install kensho-pytest
# or, in this monorepo:
pip install -e packages/pytest
The plugin auto-registers via the pytest11 entry point — no conftest.py
edits required.
Run
pytest
# => kensho-results/run.json + kensho-results/cases/*.json
# Generate the HTML report (uses the JS CLI from the same monorepo):
npx kensho generate
npx kensho open
CLI flags
--kensho-output PATH Output dir (default: ./kensho-results)
--kensho-project-name STR Project name in run.json
--kensho-project-slug STR Project slug (lowercase, alnum + dash/underscore)
--kensho-run-id STR Override the auto-generated run id
--kensho-no-severity-from-marks Don't promote @pytest.mark.<severity> to case.severity
pytest.ini / pyproject.toml [tool.pytest.ini_options] keys are also
respected: kensho_output, kensho_project_name, kensho_project_slug.
What it produces
kensho-results/run.json— run manifest (project, env, totals, timing).kensho-results/cases/<stableId>.json— one file per test case.kensho-results/attachments/<caseId>/...— files registered viakensho_pytest.attach.
Each case gets a stable id (tc_<16 hex>) hashed from its nodeid +
file path, so test history correlates across runs and across adapters
(the JS adapters use the same FNV-1a-based hash).
Markers we read
| Marker | Effect |
|---|---|
@pytest.mark.severity('critical') |
Sets case.severity. Allowed values: blocker, critical, normal, minor, trivial. |
@pytest.mark.blocker / critical / normal / minor / trivial |
Shorthand alias for the above. |
@pytest.mark.feature('Cart') |
Sets case.behavior.feature. |
@pytest.mark.epic('Checkout') |
Sets case.behavior.epic. |
@pytest.mark.story('Empty cart shows CTA') |
Sets case.behavior.scenario. |
@pytest.mark.description('Long-form...') |
Sets case.description. |
@pytest.mark.owner('alice') |
Sets case.owner. |
@pytest.mark.kensho_label(team='cart') |
Adds free-form key=value to case.labels (string only). |
@pytest.mark.kensho_link(kind='jira', url='https://…', label='PROJ-123') |
Adds an entry to case.links. |
@pytest.mark.parametrize(...) |
Each parametrized case gets case.parameters[]. |
Inline @tag syntax in test names (def test_foo_at_smoke() or
pytest.param(..., id="x@smoke")) is also picked up as a tag, mirroring
the JS adapters.
Helper API
Import the helpers from kensho_pytest. All four are no-ops outside a
running test, so it's safe to call them from shared utility code.
import kensho_pytest as kensho
def test_login(page):
with kensho.step("open the login page"):
page.goto("/login")
with kensho.step("submit credentials"):
page.fill("#user", "demo")
page.click("text=Sign in")
# nesting works — child steps roll up under the parent
with kensho.step("verify redirect"):
assert page.url.endswith("/home")
kensho.label("team", "growth")
kensho.link("https://jira.example.com/browse/PROJ-123",
kind="jira", label_text="PROJ-123")
page.screenshot(path="/tmp/login.png")
kensho.attach("/tmp/login.png", kind="screenshot")
| Helper | What it does |
|---|---|
with kensho.step(title, action=None): |
Opens a Kensho step. Nests automatically. On exception the step is marked fail and the exception re-raises. |
kensho.attach(path, kind=None, name=None, mime_type=None) |
Copies the file into kensho-results/attachments/<caseId>/ and registers it on the current case (or current step, if one is open). |
kensho.label(key, value) |
Adds a string label to the case. |
kensho.link(url, kind=None, label_text=None) |
Adds a hyperlink to the case. |
kensho.current_case_id() |
Returns the stable case id of the running test, or None. |
Captured output → logs
Pytest's captured stdout / stderr / caplog for each phase (setup, call,
teardown) is converted to entries in case.logs[]. The t field is the
millisecond offset from the test start.
Errors
call failures map to status: 'fail'; setup / teardown failures map
to status: 'broken' (these are infrastructure, not real assertion
failures). Skips at any phase map to status: 'skip'. The full
longrepr is preserved in case.errors[].stack; the first line becomes
case.errors[].message.
Environment auto-detected
GitHub Actions, CircleCI, GitLab CI, Jenkins, Buildkite, Azure DevOps — CI provider, branch, commit, run URL, OS, architecture, Python version.
Pass KR_AUTHOR, KR_COMMIT_MSG, KR_STAGE, KR_BASE_URL,
KR_APP_VERSION, KR_BUILD_NUMBER, KR_RELEASE, KR_REGION,
KR_LOCALE, KR_TRIGGER, or KR_FEATURE as env vars to populate the
matching fields on run.env.
Design notes
- Zero runtime dependencies beyond
pytestitself. The schema lives in the JS workspace; we vendor the minimum (id-hashing, status mapping, env capture) inline so the adapter installs in seconds. - The reporter never raises out of a hook — a broken adapter must not
break a test run. All errors come out as
warnings.warn. - IDs are stable across adapters: the FNV-1a hash matches the JS
stableCaseIdbyte-for-byte, sopytestandplaywrightruns of the same suite roll up to the same history on the platform.
License
Apache-2.0.
Metadata
Release files for kensho-pytest 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kensho_pytest-0.3.0.tar.gz | 23.5 kB | With provenance | Details for kensho_pytest-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kensho_pytest-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for kensho_pytest-0.3.0-py3-none-any.whl |
Total release size: 46.3 kB
Release files / kensho_pytest-0.3.0.tar.gz
| Download URL | kensho_pytest-0.3.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b68196dd973e18894938b4f0a1a061469931543951fc207017261ec310c4162d
|
|
BLAKE2b-256 checksum How to use checksums |
c8fa66c8669f36b8e89f93bcc4ac4f1569be84b9866b597057005f3be61b652f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 21, 2026.
Transparency logRelease files / kensho_pytest-0.3.0-py3-none-any.whl
| Download URL | kensho_pytest-0.3.0-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d449bf4167fd77243b0492eda4ed5b4f04d403b41a634053cc1a043313e19e89
|
|
BLAKE2b-256 checksum How to use checksums |
a82b0d54b0d7236e26cb24f23542723afd92fe34c655bf8c06db89d1a99b644f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 21, 2026.
Transparency logSecurity for kensho-pytest 0.3.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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for kensho_pytest-0.3.0.tar.gz
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 Jun 21, 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.