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

Function test_clean_display

tests/test_completion.py:966–982  ·  view source on GitHub ↗

Test display string cleaning in CompletionItem.

()

Source from the content-addressed store, hash-verified

964
965
966def test_clean_display() -> None:
967 """Test display string cleaning in CompletionItem."""
968 # Test all problematic characters being replaced by a single space.
969 # Also verify that \r\n is replaced by a single space.
970 display = "str1\r\nstr2\nstr3\rstr4\tstr5\fstr6\vstr7"
971 expected = "str1 str2 str3 str4 str5 str6 str7"
972
973 # Since display defaults to text if not provided, we test both text and display fields
974 completion_item = CompletionItem("item", display=display, display_meta=display)
975 assert completion_item.display == expected
976 assert completion_item.display_meta == expected
977
978 # Verify that text-derived display is also sanitized
979 text = "item\nwith\nnewlines"
980 expected_text_display = "item with newlines"
981 completion_item = CompletionItem(text)
982 assert completion_item.display == expected_text_display
983
984
985def test_styled_completion_sort() -> None:

Callers

nothing calls this directly

Calls 1

CompletionItemClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…