Skip to content

[FEAT]: Deprecate the rampart_sinks fixture in favor of the pytest_rampart_sinks hook#105

Open
nina-msft wants to merge 1 commit into
microsoft:mainfrom
nina-msft:dev/nina-msft/deprecate-sinks-fixture
Open

[FEAT]: Deprecate the rampart_sinks fixture in favor of the pytest_rampart_sinks hook#105
nina-msft wants to merge 1 commit into
microsoft:mainfrom
nina-msft:dev/nina-msft/deprecate-sinks-fixture

Conversation

@nina-msft

@nina-msft nina-msft commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #73. Now that the pytest_rampart_sinks hook is the supported
sink-registration API, this PR begins deprecating the legacy rampart_sinks
fixture.

Resolving the fixture now emits a DeprecationWarning (removal target: 0.3.0)
in both fixture-consumption paths:

  • Single-process_rampart_sink_bootstrap, after the fixture resolves.
  • xdist controller_resolve_sink_candidate, when it unwraps a genuine
    @pytest.fixture-form rampart_sinks (not module-level lists or plain
    callables).

The hook stays authoritative and the fixture remains a single-process fallback,
so nothing breaks for existing users — they just get a migration nudge.

Changes

  • New rampart/common/deprecation.pyemit_deprecation_warning(...),
    mirroring PyRIT's helper (qualified-name resolution + DeprecationWarning at
    stacklevel=3).
  • Wire it into the plugin.py and _xdist.py fixture-resolution paths.
  • Docs: deprecation admonitions in usage/pytest-integration.md and
    usage/xdist.md.
  • Tests: tests/unit/common/test_deprecation.py (unit) and a
    TestSinkFixtureDeprecation class in the slow aggregation suite that drives
    real subprocess pytest runs via pytester — single-process warn,
    xdist-controller warn, and list-form no-warn — replacing the previous
    MagicMock-based warn/no-warn tests.

Breaking changes

None. The fixture continues to work as a single-process fallback; it only emits
a DeprecationWarning now.

Validation

  • uv run ruff check . → all checks pass; ruff format --check clean.
  • uv run ty check → all checks passed.
  • uv run pytest tests/unit/common/test_deprecation.py tests/unit/pytest_plugin/test_xdist.py tests/unit/pytest_plugin/test_plugin.py → 145 passed.
  • uv run pytest tests/unit/pytest_plugin/test_xdist_aggregation.py -m slow → 16 passed (includes the pytester-based TestSinkFixtureDeprecation class).

Notes

  • removed_in="0.3.0" is the removal milestone for the fixture — deprecated in
    the 0.1 line, kept through 0.2, removed in 0.3 (two minor versions, per
    docs/contributing/release-process.md).
  • Implements the first of the post-merge deprecation follow-ups raised by
    @bashirpartovi.

Checklist

  • pre-commit run --all-files passes
  • Tests added or updated for changes
  • Documentation updated

@nina-msft nina-msft marked this pull request as ready for review July 7, 2026 23:17
@nina-msft nina-msft requested a review from a team July 7, 2026 23:17
@nina-msft nina-msft force-pushed the dev/nina-msft/deprecate-sinks-fixture branch from 6de45a8 to 1c373d9 Compare July 7, 2026 23:35
Comment thread docs/usage/pytest-integration.md

@spencrr spencrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! First quick pass:

  • print_deprecation_message -> log deprecation warning maybe?
  • teats have a lot of mocks -> let’s use pytester and capture warnings that way?

@nina-msft nina-msft force-pushed the dev/nina-msft/deprecate-sinks-fixture branch from 1c373d9 to cd89f7b Compare July 8, 2026 00:10
@nina-msft

Copy link
Copy Markdown
Contributor Author

@spencrr I just updated the test name to be emit_deprecation_warning before seeing your comment so that is already addressed :D I'll do another pass through the tests shortly!

The pytest_rampart_sinks hook is the supported sink registration API. Resolving the legacy rampart_sinks fixture - in the single-process bootstrap and in controller-side discovery - now emits a DeprecationWarning pointing users to the hook, scheduled for removal in 1.0.0.

Adds rampart/common/deprecation.py (mirrors PyRIT's print_deprecation_message), wires it into both fixture-consumption paths, documents the deprecation in the pytest-integration and xdist guides, and adds unit + pytester coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nina-msft nina-msft force-pushed the dev/nina-msft/deprecate-sinks-fixture branch from cd89f7b to 3ea79a3 Compare July 8, 2026 00:52
Comment thread tests/unit/pytest_plugin/test_xdist_aggregation.py
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