Test that Cmd2BaseConsole.print() calls prepare_objects_for_rendering().
(mocker: MockerFixture)
| 133 | |
| 134 | |
| 135 | def 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 | |
| 155 | def test_cmd2_base_console_log(mocker: MockerFixture) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…