Skip to content

MAINT Fix integration test import errors and runtime issues#1448

Open
romanlutz wants to merge 3 commits intoAzure:mainfrom
romanlutz:romanlutz/integration_test_fixes
Open

MAINT Fix integration test import errors and runtime issues#1448
romanlutz wants to merge 3 commits intoAzure:mainfrom
romanlutz:romanlutz/integration_test_fixes

Conversation

@romanlutz
Copy link
Contributor

Problem

Several integration test files fail to collect or run due to code issues introduced when AttackIdentifier and ScorerIdentifier were consolidated into ComponentIdentifier:

  • 3 test files fail with ImportError: cannot import name 'AttackIdentifier' from 'pyrit.identifiers' — caused by tests/integration/mocks.py importing the removed AttackIdentifier
  • 1 test file (test_azure_sql_memory_integration.py) fails with ImportError: cannot import name 'ScorerIdentifier' and additionally 2 tests fail at runtime because AttackResult is constructed with a plain
    dict for attack_identifier, but AttackResultEntry.init calls .to_dict() on it
  • 1 test file (test_hitl_gradio_integration.py) fails with ModuleNotFoundError: No module named 'rpyc' when rpyc is not installed
  • 1 source file (add_image_to_video_converter.py) causes cv2.error on headless OpenCV builds from cv2.destroyAllWindows()

Changes

tests/integration/mocks.py

  • Replace AttackIdentifier import and type hint with ComponentIdentifier

tests/integration/memory/test_azure_sql_memory_integration.py

  • Replace ScorerIdentifier import with ComponentIdentifier
  • Update get_test_scorer_identifier() to return ComponentIdentifier with scorer-specific fields in params
  • Add get_test_attack_identifier() helper returning a proper ComponentIdentifier
  • Replace 6 instances of attack_identifier={"name": "test_attack"} with get_test_attack_identifier()
  • Update assertions in roundtrip test to access fields via params dict

tests/integration/score/test_hitl_gradio_integration.py

  • Guard rpyc-dependent imports with try/except
  • Add pytestmark to skip entire module when rpyc is not installed

pyrit/prompt_converter/add_image_to_video_converter.py

  • Wrap cv2.destroyAllWindows() with contextlib.suppress(cv2.error) for headless OpenCV builds

romanlutz and others added 3 commits March 10, 2026 06:22
- Replace removed AttackIdentifier with ComponentIdentifier in integration mocks
- Replace removed ScorerIdentifier with ComponentIdentifier in azure sql memory test
- Guard rpyc import in hitl_gradio test to skip when module is unavailable
- Use contextlib.suppress for cv2.destroyAllWindows() on headless OpenCV builds

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace plain dict attack_identifier with ComponentIdentifier in
test_get_attack_results_by_harm_categories and test_get_attack_results_by_labels.
AttackResultEntry.__init__ calls .to_dict() on attack_identifier which fails on
plain dicts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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