Kensho reporter for pytest — writes kensho-results/ so the Kensho CLI can generate a rich HTML report.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kensho_pytest-0.1.1.tar.gz.
File metadata
- Download URL: kensho_pytest-0.1.1.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3957bc9c983f849c2078ed994adeb3134f3f14f81ccfdad36d4fa3313f05fb0e
|
|
| MD5 |
c9ff4a57b74ca0ad56f7268123f25254
|
|
| BLAKE2b-256 |
efa1eaf880cb67b2e750148f4aca0867bf012fae2e3a775581d3f69932b6a82e
|
Provenance
The following attestation bundles were made for kensho_pytest-0.1.1.tar.gz:
Publisher:
release-pypi.yml on brandon1794/kensho
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kensho_pytest-0.1.1.tar.gz -
Subject digest:
3957bc9c983f849c2078ed994adeb3134f3f14f81ccfdad36d4fa3313f05fb0e - Sigstore transparency entry: 1741433895
- Sigstore integration time:
-
Permalink:
brandon1794/kensho@c6eb26f99eed4152f1cd301cf6418258792f8337 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/brandon1794
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@c6eb26f99eed4152f1cd301cf6418258792f8337 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kensho_pytest-0.1.1-py3-none-any.whl.
File metadata
- Download URL: kensho_pytest-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f2f75ddba62bd8a02a4f36fc7b48f1c779e10d224a20c7caa8992ddbfa8d1e
|
|
| MD5 |
02a09f52fb9bc574ffaf6eafd5177759
|
|
| BLAKE2b-256 |
405fe7be9a497501c95301a78133aa28baadbe4d47e5638ee643b68190598e7a
|
Provenance
The following attestation bundles were made for kensho_pytest-0.1.1-py3-none-any.whl:
Publisher:
release-pypi.yml on brandon1794/kensho
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kensho_pytest-0.1.1-py3-none-any.whl -
Subject digest:
76f2f75ddba62bd8a02a4f36fc7b48f1c779e10d224a20c7caa8992ddbfa8d1e - Sigstore transparency entry: 1741433899
- Sigstore integration time:
-
Permalink:
brandon1794/kensho@c6eb26f99eed4152f1cd301cf6418258792f8337 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/brandon1794
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@c6eb26f99eed4152f1cd301cf6418258792f8337 -
Trigger Event:
push
-
Statement type: