From 28e1b89f8ec86d0401a707a78c460e05dd8e3e9c Mon Sep 17 00:00:00 2001 From: Khushi Jain Date: Thu, 19 Nov 2026 02:09:12 +0530 Subject: [PATCH 1/2] MAINT: Remove the deprecated print-scenario command from pyrit_shell --- pyrit/cli/pyrit_shell.py | 22 ---------------------- tests/unit/cli/test_pyrit_shell.py | 29 ++++++----------------------- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/pyrit/cli/pyrit_shell.py b/pyrit/cli/pyrit_shell.py index 7e1b6f09a7..db9f839192 100644 --- a/pyrit/cli/pyrit_shell.py +++ b/pyrit/cli/pyrit_shell.py @@ -98,7 +98,6 @@ class PyRITShell(cmd.Cmd): run [opts] - Run a scenario with optional parameters scenario-history [N] - List the last N (default 10) scenario runs scenario-results [id] - Inspect a run: --view overview|attacks|conversations|full - print-scenario [id] - Deprecated alias for 'scenario-results' start-server - Start a local backend server stop-server - Stop the owned backend server help [command] - Show help for a command @@ -810,27 +809,6 @@ def do_scenario_results(self, arg: str) -> None: _print_shell_exception(exc=exc) return - def do_print_scenario(self, arg: str) -> None: - """ - Print a scenario run's overview (deprecated alias for ``scenario-results``). - - Equivalent to ``scenario-results ``, whose default ``overview`` view - produces the same output. - - Usage: - print-scenario - """ - from pyrit.common import print_deprecation_message - - print_deprecation_message( - old_item="print-scenario", - new_item="scenario-results", - removed_in="1.3.0", - ) - # DeprecationWarning is suppressed by default in the REPL, so also print a visible note. - print("Note: 'print-scenario' is deprecated; use 'scenario-results ' instead.") - self.do_scenario_results(arg.strip()) - # ------------------------------------------------------------------ # Server management # ------------------------------------------------------------------ diff --git a/tests/unit/cli/test_pyrit_shell.py b/tests/unit/cli/test_pyrit_shell.py index b8d02d9449..eb181e13a7 100644 --- a/tests/unit/cli/test_pyrit_shell.py +++ b/tests/unit/cli/test_pyrit_shell.py @@ -262,12 +262,6 @@ def test_do_scenario_history_rejects_non_integer(self, shell, capsys): captured = capsys.readouterr() assert "Usage: scenario-history" in captured.out - def test_do_print_scenario_no_args(self, shell, capsys): - s, _ = shell - s.do_print_scenario("") - captured = capsys.readouterr() - assert "Usage" in captured.out - def test_do_exit(self, shell): s, client = shell result = s.do_exit("") @@ -965,8 +959,8 @@ def test_scenario_history_error(self, shell, capsys): assert "Error" in capsys.readouterr().out -class TestPrintScenarioAndHelp: - def test_print_scenario_success(self, shell): +class TestScenarioResultsAndHelp: + def test_scenario_results_empty_completed_run(self, shell): from pyrit.models import ScenarioRunState s, client = shell @@ -979,13 +973,13 @@ def test_print_scenario_success(self, shell): ) client.get_scenario_run_results_async = AsyncMock(return_value=empty_result) with patch("pyrit.cli._output.print_scenario_result_async", new_callable=AsyncMock) as mock_print: - s.do_print_scenario("rid-1") + s.do_scenario_results("rid-1") mock_print.assert_awaited_once() - def test_print_scenario_error(self, shell, capsys): + def test_scenario_results_error(self, shell, capsys): s, client = shell client.get_scenario_run_results_async = AsyncMock(side_effect=RuntimeError("oops")) - s.do_print_scenario("rid-1") + s.do_scenario_results("rid-1") assert "Error (RuntimeError): oops" in capsys.readouterr().out def test_scenario_history_read_timeout_is_not_blank(self, shell, capsys): @@ -1187,7 +1181,7 @@ def _attack(objective, outcome): class TestDoScenarioResults: - """Tests for the ``scenario-results`` command and its ``print-scenario`` alias.""" + """Tests for the ``scenario-results`` command.""" def test_no_args_prints_usage(self, shell, capsys): s, _ = shell @@ -1282,17 +1276,6 @@ def test_html_format_without_output_errors(self, shell, capsys): s.do_scenario_results("rid-1 --format html") assert "Error" in capsys.readouterr().out - def test_print_scenario_alias_warns_and_delegates(self, shell, capsys): - s, client = shell - client.get_scenario_run_results_async = AsyncMock(return_value=_attacks_scenario_result()) - with ( - patch("pyrit.cli._output.print_scenario_result_async", new_callable=AsyncMock) as mock_print, - pytest.warns(DeprecationWarning, match="print-scenario is deprecated.*Use scenario-results"), - ): - s.do_print_scenario("rid-1") - assert "deprecated" in capsys.readouterr().out.lower() - mock_print.assert_awaited_once() - def test_stop_server_close_client_swallows_errors(self, shell): s, client = shell launcher = MagicMock() From 7f10c1adcab0867d38ec6cb766b55e8cb9129b1d Mon Sep 17 00:00:00 2001 From: Roman Lutz Date: Sat, 21 Nov 2026 23:01:58 -0800 Subject: [PATCH 2/2] TEST: Drop the moved error test that duplicates test_fetch_error_is_reported TestDoScenarioResults.test_fetch_error_is_reported already covers the scenario-results fetch-error path with the same mock and assertion. Co-Authored-By: Claude Fable 5 --- tests/unit/cli/test_pyrit_shell.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/unit/cli/test_pyrit_shell.py b/tests/unit/cli/test_pyrit_shell.py index eb181e13a7..85b0a929f4 100644 --- a/tests/unit/cli/test_pyrit_shell.py +++ b/tests/unit/cli/test_pyrit_shell.py @@ -976,12 +976,6 @@ def test_scenario_results_empty_completed_run(self, shell): s.do_scenario_results("rid-1") mock_print.assert_awaited_once() - def test_scenario_results_error(self, shell, capsys): - s, client = shell - client.get_scenario_run_results_async = AsyncMock(side_effect=RuntimeError("oops")) - s.do_scenario_results("rid-1") - assert "Error (RuntimeError): oops" in capsys.readouterr().out - def test_scenario_history_read_timeout_is_not_blank(self, shell, capsys): """The run hints send users here, so a bare ReadTimeout must not print an empty error.""" import httpx