From e56e6fab0d1fd5fb693e5fc2e6ce6723fa3e8d68 Mon Sep 17 00:00:00 2001 From: Aditya <147165909+ADiTyaRaj8969@users.noreply.github.com> Date: Tue, 19 May 2026 12:20:07 +0530 Subject: [PATCH 1/3] Assert help text appears in zsh completion output for colon-containing values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing zsh tests in test_completion_option_colon.py only verified that each completion value (with its colon escaped as `\:`) appeared in the shell output. They did not verify the second half of the formatted `"value":"help"` pair that `ZshComplete.format_completion` produces, so a regression that broke help-text formatting (or that confused the colon escaping inside the help string) would not have been caught. This adds assertions that, for each of the three existing test cases (`_all`, `_partial`, `_single`), the help strings defined in `colon_example.image_desc` appear in the output where expected and do not appear where the corresponding value was filtered out. The `fake image\\: for testing` assertion (note the double-backslash before the colon) also locks in the current behavior of escaping colons inside the help string the same way they are escaped in values — which is what `ZshComplete.format_completion`'s `escape` helper does today and what zsh needs in order to render the help text correctly. --- tests/test_completion/test_completion_option_colon.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_completion/test_completion_option_colon.py b/tests/test_completion/test_completion_option_colon.py index f106eca862..947e4344a0 100644 --- a/tests/test_completion/test_completion_option_colon.py +++ b/tests/test_completion/test_completion_option_colon.py @@ -80,6 +80,8 @@ def test_completion_colon_zsh_all(): assert "alpine\\\\:hello" in result.stdout assert "alpine\\\\:latest" in result.stdout assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" in result.stdout + assert "latest alpine image" in result.stdout + assert "fake image\\\\: for testing" in result.stdout def test_completion_colon_zsh_partial(): @@ -96,6 +98,8 @@ def test_completion_colon_zsh_partial(): assert "alpine\\\\:hello" in result.stdout assert "alpine\\\\:latest" in result.stdout assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout + assert "latest alpine image" in result.stdout + assert "fake image\\\\: for testing" in result.stdout def test_completion_colon_zsh_single(): @@ -112,6 +116,8 @@ def test_completion_colon_zsh_single(): assert "alpine\\\\:hello" in result.stdout assert "alpine\\\\:latest" not in result.stdout assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout + assert "fake image\\\\: for testing" in result.stdout + assert "latest alpine image" not in result.stdout def test_completion_colon_powershell_all(): From 97f60c389d7a7bc1f271c6446bac33b2057c48d2 Mon Sep 17 00:00:00 2001 From: Aditya <147165909+ADiTyaRaj8969@users.noreply.github.com> Date: Tue, 19 May 2026 15:58:55 +0530 Subject: [PATCH 2/3] Address review: pair value/help asserts and extend to powershell + pwsh Per @svlandeg's review, the value and help-text assertions are now grouped per item so each value is immediately followed by its corresponding help string. The previously zsh-only help assertions are also extended to the powershell and pwsh tests, which use the `value:::help` output format produced by PowerShellComplete.format_completion. Per-shell summary: - bash: unchanged. BashComplete.format_completion returns `f"{item.value}"` with no help in the output, so there are no help strings to assert on. - zsh: assertions reordered so the help string follows its value; existing value assertions are unchanged in content, only in position. - powershell, pwsh: help-text assertions added in the same paired pattern, matched against the unescaped help text that appears after `:::`. All thirteen tests in tests/test_completion/test_completion_option_colon.py continue to pass (verified locally with `pytest -p no:xdist`). --- .../test_completion_option_colon.py | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/test_completion/test_completion_option_colon.py b/tests/test_completion/test_completion_option_colon.py index 947e4344a0..cb7b984696 100644 --- a/tests/test_completion/test_completion_option_colon.py +++ b/tests/test_completion/test_completion_option_colon.py @@ -77,11 +77,11 @@ def test_completion_colon_zsh_all(): "_TYPER_COMPLETE_ARGS": "colon_example.py --name ", }, ) - assert "alpine\\\\:hello" in result.stdout assert "alpine\\\\:latest" in result.stdout - assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" in result.stdout assert "latest alpine image" in result.stdout + assert "alpine\\\\:hello" in result.stdout assert "fake image\\\\: for testing" in result.stdout + assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" in result.stdout def test_completion_colon_zsh_partial(): @@ -95,11 +95,11 @@ def test_completion_colon_zsh_partial(): "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine", }, ) - assert "alpine\\\\:hello" in result.stdout assert "alpine\\\\:latest" in result.stdout - assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout assert "latest alpine image" in result.stdout + assert "alpine\\\\:hello" in result.stdout assert "fake image\\\\: for testing" in result.stdout + assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout def test_completion_colon_zsh_single(): @@ -114,10 +114,10 @@ def test_completion_colon_zsh_single(): }, ) assert "alpine\\\\:hello" in result.stdout - assert "alpine\\\\:latest" not in result.stdout - assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout assert "fake image\\\\: for testing" in result.stdout + assert "alpine\\\\:latest" not in result.stdout assert "latest alpine image" not in result.stdout + assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout def test_completion_colon_powershell_all(): @@ -132,8 +132,10 @@ def test_completion_colon_powershell_all(): "_TYPER_COMPLETE_WORD_TO_COMPLETE": "", }, ) - assert "alpine:hello" in result.stdout assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout + assert "alpine:hello" in result.stdout + assert "fake image: for testing" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout @@ -149,8 +151,10 @@ def test_completion_colon_powershell_partial(): "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine", }, ) - assert "alpine:hello" in result.stdout assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout + assert "alpine:hello" in result.stdout + assert "fake image: for testing" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout @@ -167,7 +171,9 @@ def test_completion_colon_powershell_single(): }, ) assert "alpine:hello" in result.stdout + assert "fake image: for testing" in result.stdout assert "alpine:latest" not in result.stdout + assert "latest alpine image" not in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout @@ -183,8 +189,10 @@ def test_completion_colon_pwsh_all(): }, ) - assert "alpine:hello" in result.stdout assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout + assert "alpine:hello" in result.stdout + assert "fake image: for testing" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout @@ -200,8 +208,10 @@ def test_completion_colon_pwsh_partial(): "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine", }, ) - assert "alpine:hello" in result.stdout assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout + assert "alpine:hello" in result.stdout + assert "fake image: for testing" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout @@ -218,7 +228,9 @@ def test_completion_colon_pwsh_single(): }, ) assert "alpine:hello" in result.stdout + assert "fake image: for testing" in result.stdout assert "alpine:latest" not in result.stdout + assert "latest alpine image" not in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout From 67d3d62830fdcdc351304422ae377356c16d68b6 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 19 May 2026 13:31:38 +0200 Subject: [PATCH 3/3] restore original order to minimize PR diff --- .../test_completion_option_colon.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_completion/test_completion_option_colon.py b/tests/test_completion/test_completion_option_colon.py index cb7b984696..8455fb9620 100644 --- a/tests/test_completion/test_completion_option_colon.py +++ b/tests/test_completion/test_completion_option_colon.py @@ -77,10 +77,10 @@ def test_completion_colon_zsh_all(): "_TYPER_COMPLETE_ARGS": "colon_example.py --name ", }, ) - assert "alpine\\\\:latest" in result.stdout - assert "latest alpine image" in result.stdout assert "alpine\\\\:hello" in result.stdout assert "fake image\\\\: for testing" in result.stdout + assert "alpine\\\\:latest" in result.stdout + assert "latest alpine image" in result.stdout assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" in result.stdout @@ -95,10 +95,10 @@ def test_completion_colon_zsh_partial(): "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine", }, ) - assert "alpine\\\\:latest" in result.stdout - assert "latest alpine image" in result.stdout assert "alpine\\\\:hello" in result.stdout assert "fake image\\\\: for testing" in result.stdout + assert "alpine\\\\:latest" in result.stdout + assert "latest alpine image" in result.stdout assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout @@ -132,10 +132,10 @@ def test_completion_colon_powershell_all(): "_TYPER_COMPLETE_WORD_TO_COMPLETE": "", }, ) - assert "alpine:latest" in result.stdout - assert "latest alpine image" in result.stdout assert "alpine:hello" in result.stdout assert "fake image: for testing" in result.stdout + assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout @@ -151,10 +151,10 @@ def test_completion_colon_powershell_partial(): "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine", }, ) - assert "alpine:latest" in result.stdout - assert "latest alpine image" in result.stdout assert "alpine:hello" in result.stdout assert "fake image: for testing" in result.stdout + assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout @@ -189,10 +189,10 @@ def test_completion_colon_pwsh_all(): }, ) - assert "alpine:latest" in result.stdout - assert "latest alpine image" in result.stdout assert "alpine:hello" in result.stdout assert "fake image: for testing" in result.stdout + assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout @@ -208,10 +208,10 @@ def test_completion_colon_pwsh_partial(): "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine", }, ) - assert "alpine:latest" in result.stdout - assert "latest alpine image" in result.stdout assert "alpine:hello" in result.stdout assert "fake image: for testing" in result.stdout + assert "alpine:latest" in result.stdout + assert "latest alpine image" in result.stdout assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout