Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions pyrit/cli/pyrit_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class PyRITShell(cmd.Cmd):
run <scenario> [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
Expand Down Expand Up @@ -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 <id>``, whose default ``overview`` view
produces the same output.

Usage:
print-scenario <scenario_result_id>
"""
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 <id>' instead.")
self.do_scenario_results(arg.strip())

# ------------------------------------------------------------------
# Server management
# ------------------------------------------------------------------
Expand Down
31 changes: 4 additions & 27 deletions tests/unit/cli/test_pyrit_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand Down Expand Up @@ -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
Expand All @@ -979,15 +973,9 @@ 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):
s, client = shell
client.get_scenario_run_results_async = AsyncMock(side_effect=RuntimeError("oops"))
s.do_print_scenario("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
Expand Down Expand Up @@ -1187,7 +1175,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
Expand Down Expand Up @@ -1282,17 +1270,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()
Expand Down
Loading