Skip to content

TEST: Add unit tests for pyrit/models/ module#1601

Merged
romanlutz merged 4 commits intomicrosoft:mainfrom
romanlutz:test/models-coverage
Apr 13, 2026
Merged

TEST: Add unit tests for pyrit/models/ module#1601
romanlutz merged 4 commits intomicrosoft:mainfrom
romanlutz:test/models-coverage

Conversation

@romanlutz
Copy link
Copy Markdown
Contributor

Summary

Adds unit tests for 10 previously untested model files including seed models.

New Test Files

Source File Tests Coverage
chat_message.py 17 ToolCall, ChatMessage (init, serialization, roles), ChatMessagesDataset
conversation_reference.py 10 ConversationType enum, frozen dataclass, hash, equality
conversation_stats.py 5 Defaults, values, frozen immutability
question_answering.py 14 QuestionChoice, QuestionAnsweringEntry, Dataset
scenario_result.py 12 ScenarioIdentifier, ScenarioResult (strategies, objectives, success rate)
strategy_result.py 3 duplicate() deep copy, independence
seeds/seed_attack_group.py 7 Valid init, objective property, validation errors
seeds/seed_dataset.py 18 Init, get_values, random, from_dict, grouping, deprecation
seeds/seed_objective.py 7 Init, data_type, technique errors, Jinja rendering
seeds/seed_prompt.py 14 Init, data_type inference, from_messages

Testing

All 121 tests pass locally.

romanlutz and others added 3 commits April 11, 2026 18:07
Adds tests for 10 previously untested model files:
- chat_message.py (ToolCall, ChatMessage, ChatMessagesDataset)
- conversation_reference.py (frozen, hash, equality)
- conversation_stats.py (defaults, frozen)
- question_answering.py (QuestionChoice, QuestionAnsweringEntry)
- scenario_result.py (ScenarioIdentifier, ScenarioResult)
- strategy_result.py (duplicate, deep copy)
- seeds: seed_attack_group.py, seed_dataset.py,
  seed_objective.py, seed_prompt.py

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rize

- test_chat_message: remove redundant test_to_dict_includes_non_none
- test_scenario_result: use class-level @patch instead of per-method
- test_seed_prompt: parametrize data type inference tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz merged commit bce410c into microsoft:main Apr 13, 2026
39 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