What
Message.duplicate_message() is marked for removal in 0.16.0, with Message.duplicate() as the canonical replacement. The deprecated method is a thin wrapper that just calls self.duplicate() and returns the result.
Internal test code still exercises the deprecated wrapper. TestMessageDuplication in tests/unit/models/test_message.py has six tests that all call .duplicate_message(), which produces seven DeprecationWarning lines in every unit-suite run.
Why the tests target the deprecated method
The class predates the rename. Its tests cover the duplication behavior itself (new IDs, deep copy, preserved content, fresh timestamp), not the deprecated entry point. Pointing them at duplicate() keeps coverage identical and removes the warnings.
Convention for the deprecated path
PyRIT already uses an emits_deprecation_warning_and_delegates pattern for testing deprecated wrappers (see tests/unit/memory/storage/test_serializers.py). The same pattern fits here: one focused test that confirms duplicate_message() warns and still returns a working duplicate, keeping the deprecated contract under test until 0.16.0 removal.
Proposed fix
Update the six TestMessageDuplication tests to call Message.duplicate(), refresh names and the class docstring, and add one test_duplicate_message_emits_deprecation_warning_and_delegates test following the established PyRIT convention. PR to follow.
What
Message.duplicate_message()is marked for removal in 0.16.0, withMessage.duplicate()as the canonical replacement. The deprecated method is a thin wrapper that just callsself.duplicate()and returns the result.Internal test code still exercises the deprecated wrapper.
TestMessageDuplicationintests/unit/models/test_message.pyhas six tests that all call.duplicate_message(), which produces sevenDeprecationWarninglines in every unit-suite run.Why the tests target the deprecated method
The class predates the rename. Its tests cover the duplication behavior itself (new IDs, deep copy, preserved content, fresh timestamp), not the deprecated entry point. Pointing them at
duplicate()keeps coverage identical and removes the warnings.Convention for the deprecated path
PyRIT already uses an
emits_deprecation_warning_and_delegatespattern for testing deprecated wrappers (seetests/unit/memory/storage/test_serializers.py). The same pattern fits here: one focused test that confirmsduplicate_message()warns and still returns a working duplicate, keeping the deprecated contract under test until 0.16.0 removal.Proposed fix
Update the six
TestMessageDuplicationtests to callMessage.duplicate(), refresh names and the class docstring, and add onetest_duplicate_message_emits_deprecation_warning_and_delegatestest following the established PyRIT convention. PR to follow.