From e54c2fc65bd56149920c973e236079bb2cc0f2f1 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 3 Apr 2026 07:53:25 -0400 Subject: [PATCH] add more tests for clitoolbar.py bringing coverage of the file to 100% --- test/pytests/test_clitoolbar.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/pytests/test_clitoolbar.py b/test/pytests/test_clitoolbar.py index cffe0bb1..71c64d66 100644 --- a/test/pytests/test_clitoolbar.py +++ b/test/pytests/test_clitoolbar.py @@ -95,6 +95,26 @@ def test_create_toolbar_tokens_func_applies_custom_format(monkeypatch) -> None: assert ("class:bottom-toolbar", "Refreshing completions…") in result +def test_create_toolbar_tokens_func_replaces_default_toolbar_for_plain_custom_format(monkeypatch) -> None: + mycli = make_mycli(multi_line=True, toolbar_error_message='boom', refreshing=True) + monkeypatch.setattr(clitoolbar.special, 'get_current_delimiter', lambda: '$$') + + formatted = [('class:bottom-toolbar', 'PLAIN CUSTOM')] + to_formatted_text = MagicMock(return_value=formatted) + monkeypatch.setattr(clitoolbar, 'to_formatted_text', to_formatted_text) + + toolbar = clitoolbar.create_toolbar_tokens_func(mycli, lambda: True, 'fmt') + result = toolbar() + + mycli.get_custom_toolbar.assert_called_once_with('fmt') + to_formatted_text.assert_called_once_with('custom toolbar', style='class:bottom-toolbar') + assert ('class:bottom-toolbar', 'PLAIN CUSTOM') in result + assert ('class:bottom-toolbar', '[Tab] Complete') not in result + assert ('class:bottom-toolbar', '[F1] Help') not in result + assert ('class:bottom-toolbar', 'right-arrow accepts full-line suggestion') in result + assert ('class:bottom-toolbar.transaction.failed', 'boom') in result + + @pytest.mark.parametrize( ('input_mode', 'expected'), [