Test get_completions with a completion error.
(self, mock_cmd_app: MockCmd, monkeypatch)
| 335 | assert cmd2_completions.hint in str(args[0]) |
| 336 | |
| 337 | def test_get_completions_with_error(self, mock_cmd_app: MockCmd, monkeypatch) -> None: |
| 338 | """Test get_completions with a completion error.""" |
| 339 | mock_print = Mock() |
| 340 | monkeypatch.setattr(pt_utils, "print_formatted_text", mock_print) |
| 341 | |
| 342 | completer = pt_utils.Cmd2Completer(cast(Any, mock_cmd_app)) |
| 343 | |
| 344 | document = Document("", cursor_position=0) |
| 345 | |
| 346 | # Set up matches |
| 347 | cmd2_completions = cmd2.Completions(error="Completion Error") |
| 348 | mock_cmd_app.complete.return_value = cmd2_completions |
| 349 | |
| 350 | completions = list(completer.get_completions(document, None)) |
| 351 | assert not completions |
| 352 | |
| 353 | # Verify that only the completion error printed |
| 354 | assert mock_print.call_count == 1 |
| 355 | args, _ = mock_print.call_args |
| 356 | assert cmd2_completions.error in str(args[0]) |
| 357 | |
| 358 | @pytest.mark.parametrize( |
| 359 | # search_text_offset is the starting index of the user-provided search text within a full match. |
nothing calls this directly
no test coverage detected