Skip to content

TEST: Assert Registry.get_registry_singleton return types (P311-04) - #3770

Merged
Roman Lutz (romanlutz) merged 11 commits into
microsoft:mainfrom
WaqarAnwar:test/registry-singleton-assert-type
Nov 1, 2026
Merged

Roman Lutz (romanlutz) merged 11 commits into
microsoft:mainfrom
WaqarAnwar:test/registry-singleton-assert-type

Conversation

@WaqarAnwar

Copy link
Copy Markdown
Contributor

Summary

  • Add type-regression checks with assert_type for Registry.get_registry_singleton in tests/unit/registry/test_registry.py.
  • Verify the Self return type resolves to the concrete subclass for both SlowConstructingRegistry (same-class convergence test) and OtherSlowConstructingRegistry (unrelated-class isolation test).
  • Retain the existing singleton identity and isinstance checks; no production code, synchronization, or public signatures change.

Verification

  • pytest tests/unit/registry/test_registry.py: 29 passed.
  • ty check tests/unit/registry/test_registry.py: all checks passed.
  • Confirmed the checks are effective: swapping one assertion to the wrong registry class makes ty report type-assertion-failure.

Part of #3166 (Item P311-04)

Add assert_type checks for SlowConstructingRegistry and
OtherSlowConstructingRegistry singleton results so the Self return
type is covered by the type checker, alongside the existing identity
and isinstance checks.
@romanlutz Roman Lutz (romanlutz) self-assigned this Nov 1, 2026
@WaqarAnwar

Copy link
Copy Markdown
Contributor Author

Hello Roman Lutz (@romanlutz) ,

One test failed with summary as below:
FAILED tests/unit/backend/test_scenario_hierarchy_parity.py::test_hierarchy_traversal_halts_immediately_on_budget_exhaustion - AssertionError: Expected <0.05s, got 1.6359s
assert 1.6358961960000329 < 0.05
=== 1 failed, 32122 passed, 461 skipped, 1770 warnings in 494.95s (0:08:14) ====
make: *** [Makefile:46: unit-test-junit] Error 1
Error: Process completed with exit code 2.

I've fixed the test and pushed it. Please review it here:
e9bd3df

Thanks. Moreover, I'll wait in case I am assigned the issue related to this PR, if yes then it'll be all good to go

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 1, 2026
Roman Lutz (romanlutz) added a commit to FazeelUsmani/PyRIT that referenced this pull request Nov 1, 2026
Integrate microsoft#3770, microsoft#3697 and microsoft#3695 normally. As requested, retain the upstream deterministic one-node mapping-budget assertion, truncation and exact totals; do not restore the removed wall-clock benchmark.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merged via the queue into microsoft:main with commit cba24a0 Nov 1, 2026
61 checks passed
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