MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / test_cmd2_base_console_print

Function test_cmd2_base_console_print

tests/test_rich_utils.py:135–152  ·  view source on GitHub ↗

Test that Cmd2BaseConsole.print() calls prepare_objects_for_rendering().

(mocker: MockerFixture)

Source from the content-addressed store, hash-verified

133
134
135def test_cmd2_base_console_print(mocker: MockerFixture) -> None:
136 """Test that Cmd2BaseConsole.print() calls prepare_objects_for_rendering()."""
137 # Mock prepare_objects_for_rendering to return a specific value
138 prepared_val = ("prepared",)
139 mock_prepare = mocker.patch("cmd2.rich_utils.prepare_objects_for_rendering", return_value=prepared_val)
140
141 # Mock the superclass print() method
142 mock_super_print = mocker.patch("rich.console.Console.print")
143
144 console = ru.Cmd2BaseConsole()
145 console.print("hello")
146
147 # Verify that prepare_objects_for_rendering() was called with the input objects
148 mock_prepare.assert_called_once_with("hello")
149
150 # Verify that the superclass print() method was called with the prepared objects
151 args, _ = mock_super_print.call_args
152 assert args == prepared_val
153
154
155def test_cmd2_base_console_log(mocker: MockerFixture) -> None:

Callers

nothing calls this directly

Calls 1

printMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…