diff --git a/pyrit/output/attack_result/pretty.py b/pyrit/output/attack_result/pretty.py index fa4a77b4fd..ce066f35df 100644 --- a/pyrit/output/attack_result/pretty.py +++ b/pyrit/output/attack_result/pretty.py @@ -158,6 +158,16 @@ async def _render_conversation_async( include_reasoning_trace=include_reasoning_trace, ) + async def print_conversation_async( + self, result: AttackResult, *, include_scores: bool = False, include_reasoning_trace: bool = False + ) -> None: + """Use ``write_async`` instead. This method is deprecated.""" + print_deprecation_message(old_item="print_conversation_async", new_item="write_async", removed_in="2.0") + content = await self._render_conversation_async( + result, include_scores=include_scores, include_reasoning_trace=include_reasoning_trace + ) + await self._write_async(content) + async def output_conversation_async( self, result: AttackResult, *, include_scores: bool = False, include_reasoning_trace: bool = False ) -> None: diff --git a/tests/unit/output/attack_result/test_pretty.py b/tests/unit/output/attack_result/test_pretty.py index d9e4ee75de..b62d7fe2b4 100644 --- a/tests/unit/output/attack_result/test_pretty.py +++ b/tests/unit/output/attack_result/test_pretty.py @@ -339,6 +339,12 @@ async def test_print_result_async_emits_deprecation_warning_and_still_writes(pri assert "ATTACK RESULT" in capsys.readouterr().out +async def test_print_conversation_async_emits_deprecation_warning(printer, attack_result, capsys): + with pytest.warns(DeprecationWarning, match="print_conversation_async"): + await printer.print_conversation_async(attack_result) + assert "No conversation found" in capsys.readouterr().out + + async def test_output_conversation_async_emits_deprecation_warning(printer, attack_result, capsys): with pytest.warns(DeprecationWarning, match="output_conversation_async"): await printer.output_conversation_async(attack_result)