TEST: Add unit tests for pyrit/common/ utilities#1600
Merged
romanlutz merged 5 commits intomicrosoft:mainfrom Apr 15, 2026
Merged
TEST: Add unit tests for pyrit/common/ utilities#1600romanlutz merged 5 commits intomicrosoft:mainfrom
romanlutz merged 5 commits intomicrosoft:mainfrom
Conversation
Adds tests for 10 previously untested utility files: - apply_defaults.py (decorator, sentinel, registry) - csv_helper.py (read/write/roundtrip) - data_url_converter.py (format support, encoding) - deprecation.py (warnings for callables, classes) - display_response.py (notebook skip, image display) - path.py (constants, git_repo detection, default paths) - question_answer_helpers.py (prompt formatting) - singleton.py (identity, distinct classes) - utils.py (combine_list, to_sha256) - yaml_loadable.py (basic load, from_dict, errors) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts: # tests/unit/common/test_csv_helper.py
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds missing unit coverage for pyrit/common/ utilities by introducing new pytest tests across multiple helper modules.
Changes:
- Added unit tests for YAML loading (
YamlLoadable), hashing/list utilities, singleton metaclass behavior, and prompt construction helpers. - Added unit tests for filesystem/path constants/helpers, image display behavior, deprecation warnings, CSV read/write helpers, and data-url conversion.
- Introduced fixtures and mocking for async I/O and notebook-dependent behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/common/test_apply_defaults.py | Covers default registry behavior and @apply_defaults decorator scenarios |
| tests/unit/common/test_csv_helper.py | Adds coverage for CSV read/write and roundtrip behavior |
| tests/unit/common/test_data_url_converter.py | Adds coverage for supported formats, errors, and data URL output |
| tests/unit/common/test_deprecation.py | Validates warning emission/message contents across input types |
| tests/unit/common/test_display_response.py | Tests notebook gating, blocked content logging, and image display flow with mocks |
| tests/unit/common/test_path.py | Tests path constants plus in_git_repo / get_default_data_path |
| tests/unit/common/test_question_answer_helpers.py | Validates evaluation prompt formatting for Q/A entries |
| tests/unit/common/test_singleton.py | Tests singleton identity, class separation, and init-arg preservation |
| tests/unit/common/test_utils.py | Tests list-combining behavior and SHA256 determinism/known value |
| tests/unit/common/test_yaml_loadable.py | Tests YAML load success paths plus missing/invalid file error behavior |
rlundeen2
approved these changes
Apr 14, 2026
Contributor
rlundeen2
left a comment
There was a problem hiding this comment.
I like the copilot review suggestions, but no blockers!
- test_path: Assert is_absolute() instead of exists() for CI stability - test_display_response: Patch display at module namespace instead of builtins - test_singleton: Use autouse fixture for cleanup instead of inline cleanup - test_yaml_loadable: Use Path() instead of string literal for consistency Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds unit tests for 10 previously untested utility files in pyrit/common/.
New Test Files
Testing
All 71 tests pass locally.