Skip to content

Python(feat): pytest plugin improvements#567

Merged
alexluck-sift merged 14 commits into
al/python/feat/pytest-dev-branchfrom
al/python/pytest-plugin-idiomatic
May 19, 2026
Merged

Python(feat): pytest plugin improvements#567
alexluck-sift merged 14 commits into
al/python/feat/pytest-dev-branchfrom
al/python/pytest-plugin-idiomatic

Conversation

@alexluck-sift
Copy link
Copy Markdown
Collaborator

@alexluck-sift alexluck-sift commented May 15, 2026

Summary

  • Promote the plugin to sift_client.pytest_plugin (was buried at util/test_results/pytest_util) so users wire it in with a single pytest_plugins = ["sift_client.pytest_plugin"].
  • Add ini keys mirroring every CLI flag and a default sift_client fixture that reads SIFT_* env vars with sift_grpc_uri / sift_rest_uri ini fallback, so per-project config can live in pyproject.toml.
  • Reorganize plugin tests into _tests/pytest_plugin/ so each follow-up PR drops a file rather than appending to a monolith.
  • Add sift_include / sift_exclude markers and a sift_test_results_autouse ini key so projects scope which tests produce Sift reports. Closest marker wins, defaults to the ini value. Bulk-apply per directory with pytest_collection_modifyitems in a conftest.
  • Gate the autouse fixtures per test, with report_context created lazily. Mixed unit/integration suites can share one pytest invocation without unit tests paying the backend round-trip.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

Python docs preview: https://sift-stack.github.io/sift/python/pr-567/

Deployed from 6aa83ad. The link may take up to a minute to become live as GitHub Pages propagates.

@alexluck-sift alexluck-sift changed the base branch from main to al/python/feat/pytest-dev-branch May 16, 2026 00:07
@alexluck-sift alexluck-sift requested a review from ian-sift May 18, 2026 17:30
@alexluck-sift alexluck-sift marked this pull request as ready for review May 18, 2026 17:30
Comment thread python/lib/sift_client/pytest_plugin.py Outdated
Comment thread python/lib/sift_client/pytest_plugin.py
@alexluck-sift alexluck-sift requested a review from ian-sift May 18, 2026 22:23
@alexluck-sift alexluck-sift merged commit 0bb2d5a into al/python/feat/pytest-dev-branch May 19, 2026
18 checks passed
@alexluck-sift alexluck-sift deleted the al/python/pytest-plugin-idiomatic branch May 19, 2026 13:25
alexluck-sift added a commit that referenced this pull request May 19, 2026
…t-offline and --sift-disabled

Replaces the per-fixture connection gate from #567 (which made
`report_context` / `step` / `module_substep` yield None on a failed
ping, breaking user code that calls `step.measure(...)`) with two
explicit modes:

* `--sift-offline` writes every create/update to the JSONL log file
  for later replay via `import-test-result-log`. The session-start
  ping is skipped and the replay subprocess is not spawned at session
  end. Combining with `--sift-log-file=none` is rejected as a usage
  error since the log file is the sole sink.

* `--sift-disabled` skips Sift entirely. Autouse fixtures yield stub
  objects (`_NoopStep`, `_NoopReportContext`) that share the bounds
  helpers from `bounds`, so `step.measure(...)` still returns real
  pass/fail booleans without any Sift configuration. Also honored via
  the `SIFT_DISABLED` env var. The two modes are mutually exclusive.

Online mode now fail-fasts at session start: a failed ping aborts the
session with `pytest.UsageError` naming both flags as escape hatches,
instead of letting fixtures silently no-op.

Preserves #567's marker system (`sift_include` / `sift_exclude` +
`sift_test_results_autouse` ini key), lazy `report_context`, per-module
gate, URI ini fallbacks, and the `_Option` CLI+ini plumbing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants