33import sys
44
55from . import path_example as mod
6+ from . import path_typergroup_example as typergroup_mod
67
78
89def test_script ():
@@ -28,3 +29,191 @@ def test_completion_path_bash():
2829 },
2930 )
3031 assert result .returncode == 0
32+
33+
34+ def test_completion_path_zsh_empty ():
35+ result = subprocess .run (
36+ [sys .executable , "-m" , "coverage" , "run" , mod .__file__ , " " ],
37+ capture_output = True ,
38+ encoding = "utf-8" ,
39+ env = {
40+ ** os .environ ,
41+ "_PATH_EXAMPLE.PY_COMPLETE" : "complete_zsh" ,
42+ "_TYPER_COMPLETE_ARGS" : "path_example.py " ,
43+ },
44+ )
45+ assert result .returncode == 0
46+ assert "_arguments" not in result .stdout
47+
48+
49+ def test_completion_path_zsh_partial ():
50+ result = subprocess .run (
51+ [sys .executable , "-m" , "coverage" , "run" , mod .__file__ , " " ],
52+ capture_output = True ,
53+ encoding = "utf-8" ,
54+ env = {
55+ ** os .environ ,
56+ "_PATH_EXAMPLE.PY_COMPLETE" : "complete_zsh" ,
57+ "_TYPER_COMPLETE_ARGS" : "path_example.py /tmp/some_part" ,
58+ },
59+ )
60+ assert result .returncode == 0
61+ assert "_arguments" not in result .stdout
62+
63+
64+ def test_completion_typergroup_path_zsh_empty ():
65+ result = subprocess .run (
66+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
67+ capture_output = True ,
68+ encoding = "utf-8" ,
69+ env = {
70+ ** os .environ ,
71+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_zsh" ,
72+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input " ,
73+ },
74+ )
75+ assert result .returncode == 0
76+ assert "_arguments" not in result .stdout
77+
78+
79+ def test_completion_typergroup_path_zsh_partial ():
80+ result = subprocess .run (
81+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
82+ capture_output = True ,
83+ encoding = "utf-8" ,
84+ env = {
85+ ** os .environ ,
86+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_zsh" ,
87+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input /tmp/test" ,
88+ },
89+ )
90+ assert result .returncode == 0
91+ assert "_arguments" not in result .stdout
92+
93+
94+ def test_completion_typergroup_flags_zsh ():
95+ result = subprocess .run (
96+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
97+ capture_output = True ,
98+ encoding = "utf-8" ,
99+ env = {
100+ ** os .environ ,
101+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_zsh" ,
102+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --" ,
103+ },
104+ )
105+ assert result .returncode == 0
106+ assert "_arguments" in result .stdout
107+ assert "--input" in result .stdout
108+ assert "--count" in result .stdout
109+
110+
111+ def test_completion_typergroup_path_bash_empty ():
112+ result = subprocess .run (
113+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
114+ capture_output = True ,
115+ encoding = "utf-8" ,
116+ env = {
117+ ** os .environ ,
118+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_bash" ,
119+ "COMP_WORDS" : "path_typergroup_example.py sub process --input " ,
120+ "COMP_CWORD" : "4" ,
121+ },
122+ )
123+ assert result .returncode == 0
124+ assert result .stdout .strip () == ""
125+
126+
127+ def test_completion_typergroup_path_bash_partial ():
128+ result = subprocess .run (
129+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
130+ capture_output = True ,
131+ encoding = "utf-8" ,
132+ env = {
133+ ** os .environ ,
134+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_bash" ,
135+ "COMP_WORDS" : "path_typergroup_example.py sub process --input /tmp/test" ,
136+ "COMP_CWORD" : "4" ,
137+ },
138+ )
139+ assert result .returncode == 0
140+ assert result .stdout .strip () == ""
141+
142+
143+ def test_completion_typergroup_flags_bash ():
144+ result = subprocess .run (
145+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
146+ capture_output = True ,
147+ encoding = "utf-8" ,
148+ env = {
149+ ** os .environ ,
150+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_bash" ,
151+ "COMP_WORDS" : "path_typergroup_example.py sub process --" ,
152+ "COMP_CWORD" : "3" ,
153+ },
154+ )
155+ assert result .returncode == 0
156+ assert "--input" in result .stdout
157+ assert "--count" in result .stdout
158+
159+
160+ def test_completion_typergroup_path_fish_is_args ():
161+ result = subprocess .run (
162+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
163+ capture_output = True ,
164+ encoding = "utf-8" ,
165+ env = {
166+ ** os .environ ,
167+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_fish" ,
168+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input /tmp/test" ,
169+ "_TYPER_COMPLETE_FISH_ACTION" : "is-args" ,
170+ },
171+ )
172+ assert result .returncode != 0
173+
174+
175+ def test_completion_typergroup_path_fish_get_args ():
176+ result = subprocess .run (
177+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
178+ capture_output = True ,
179+ encoding = "utf-8" ,
180+ env = {
181+ ** os .environ ,
182+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_fish" ,
183+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input /tmp/test" ,
184+ "_TYPER_COMPLETE_FISH_ACTION" : "get-args" ,
185+ },
186+ )
187+ assert result .stdout .strip () == ""
188+
189+
190+ def test_completion_typergroup_path_powershell_empty ():
191+ result = subprocess .run (
192+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
193+ capture_output = True ,
194+ encoding = "utf-8" ,
195+ env = {
196+ ** os .environ ,
197+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_powershell" ,
198+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input " ,
199+ "_TYPER_COMPLETE_WORD_TO_COMPLETE" : "" ,
200+ },
201+ )
202+ assert result .returncode == 0
203+ assert result .stdout .strip () == ""
204+
205+
206+ def test_completion_typergroup_path_powershell_partial ():
207+ result = subprocess .run (
208+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
209+ capture_output = True ,
210+ encoding = "utf-8" ,
211+ env = {
212+ ** os .environ ,
213+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_powershell" ,
214+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input /tmp/test" ,
215+ "_TYPER_COMPLETE_WORD_TO_COMPLETE" : "/tmp/test" ,
216+ },
217+ )
218+ assert result .returncode == 0
219+ assert result .stdout .strip () == ""
0 commit comments