Skip to content

MAINT TestMessageDuplication still calls deprecated Message.duplicate_message() #2008

@immu4989

Description

@immu4989

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions