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,206 @@ 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_dir_zsh ():
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_zsh" ,
119+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub export --output-dir " ,
120+ },
121+ )
122+ assert result .returncode == 0
123+ assert "_path_files -/" in result .stdout
124+
125+
126+ def test_completion_typergroup_path_bash_empty ():
127+ result = subprocess .run (
128+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
129+ capture_output = True ,
130+ encoding = "utf-8" ,
131+ env = {
132+ ** os .environ ,
133+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_bash" ,
134+ "COMP_WORDS" : "path_typergroup_example.py sub process --input " ,
135+ "COMP_CWORD" : "4" ,
136+ },
137+ )
138+ assert result .returncode == 0
139+ assert result .stdout .strip () == ""
140+
141+
142+ def test_completion_typergroup_path_bash_partial ():
143+ result = subprocess .run (
144+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
145+ capture_output = True ,
146+ encoding = "utf-8" ,
147+ env = {
148+ ** os .environ ,
149+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_bash" ,
150+ "COMP_WORDS" : "path_typergroup_example.py sub process --input /tmp/test" ,
151+ "COMP_CWORD" : "4" ,
152+ },
153+ )
154+ assert result .returncode == 0
155+ assert result .stdout .strip () == ""
156+
157+
158+ def test_completion_typergroup_flags_bash ():
159+ result = subprocess .run (
160+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
161+ capture_output = True ,
162+ encoding = "utf-8" ,
163+ env = {
164+ ** os .environ ,
165+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_bash" ,
166+ "COMP_WORDS" : "path_typergroup_example.py sub process --" ,
167+ "COMP_CWORD" : "3" ,
168+ },
169+ )
170+ assert result .returncode == 0
171+ assert "--input" in result .stdout
172+ assert "--count" in result .stdout
173+
174+
175+ def test_completion_typergroup_path_fish_is_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" : "is-args" ,
185+ },
186+ )
187+ assert result .returncode != 0
188+
189+
190+ def test_completion_typergroup_path_fish_get_args ():
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_fish" ,
198+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input /tmp/test" ,
199+ "_TYPER_COMPLETE_FISH_ACTION" : "get-args" ,
200+ },
201+ )
202+ assert result .stdout .strip () == ""
203+
204+
205+ def test_completion_typergroup_path_powershell_empty ():
206+ result = subprocess .run (
207+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
208+ capture_output = True ,
209+ encoding = "utf-8" ,
210+ env = {
211+ ** os .environ ,
212+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_powershell" ,
213+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input " ,
214+ "_TYPER_COMPLETE_WORD_TO_COMPLETE" : "" ,
215+ },
216+ )
217+ assert result .returncode == 0
218+ assert result .stdout .strip () == ""
219+
220+
221+ def test_completion_typergroup_path_powershell_partial ():
222+ result = subprocess .run (
223+ [sys .executable , "-m" , "coverage" , "run" , typergroup_mod .__file__ , " " ],
224+ capture_output = True ,
225+ encoding = "utf-8" ,
226+ env = {
227+ ** os .environ ,
228+ "_PATH_TYPERGROUP_EXAMPLE.PY_COMPLETE" : "complete_powershell" ,
229+ "_TYPER_COMPLETE_ARGS" : "path_typergroup_example.py sub process --input /tmp/test" ,
230+ "_TYPER_COMPLETE_WORD_TO_COMPLETE" : "/tmp/test" ,
231+ },
232+ )
233+ assert result .returncode == 0
234+ assert result .stdout .strip () == ""
0 commit comments