@@ -104,6 +104,60 @@ class CLIShellFixture(t.NamedTuple):
104104]
105105
106106
107+ class CLIShellTargetMissingFixture (t .NamedTuple ):
108+ """Test fixture for tmuxp shell target missing tests."""
109+
110+ test_id : str
111+ cli_args : list [str ]
112+ inputs : list [t .Any ]
113+ env : dict [t .Any , t .Any ]
114+ template_ctx : dict [str , str ]
115+ exception : type [exc .TmuxpException | subprocess .CalledProcessError ]
116+ message : str
117+
118+
119+ TEST_SHELL_TARGET_MISSING_FIXTURES : list [CLIShellTargetMissingFixture ] = [
120+ CLIShellTargetMissingFixture (
121+ test_id = "nonexistent_socket" ,
122+ cli_args = ["-LDoesNotExist" , "-c" , "print(str(server.socket_name))" ],
123+ inputs = [],
124+ env = {},
125+ template_ctx = {},
126+ exception = subprocess .CalledProcessError ,
127+ message = r".*DoesNotExist.*" ,
128+ ),
129+ CLIShellTargetMissingFixture (
130+ test_id = "nonexistent_session" ,
131+ cli_args = [
132+ "-L{SOCKET_NAME}" ,
133+ "nonexistent_session" ,
134+ "-c" ,
135+ "print(str(server.socket_name))" ,
136+ ],
137+ inputs = [],
138+ env = {},
139+ template_ctx = {"session_name" : "nonexistent_session" },
140+ exception = exc .TmuxpException ,
141+ message = "Session not found: nonexistent_session" ,
142+ ),
143+ CLIShellTargetMissingFixture (
144+ test_id = "nonexistent_window" ,
145+ cli_args = [
146+ "-L{SOCKET_NAME}" ,
147+ "{SESSION_NAME}" ,
148+ "nonexistent_window" ,
149+ "-c" ,
150+ "print(str(server.socket_name))" ,
151+ ],
152+ inputs = [],
153+ env = {},
154+ template_ctx = {"window_name" : "nonexistent_window" },
155+ exception = exc .TmuxpException ,
156+ message = "Window not found: {WINDOW_NAME}" ,
157+ ),
158+ ]
159+
160+
107161@pytest .mark .parametrize ("cli_cmd" , [["shell" ], ["shell" , "--pdb" ]])
108162@pytest .mark .parametrize (
109163 list (CLIShellFixture ._fields ),
@@ -159,47 +213,13 @@ def test_shell(
159213 ],
160214)
161215@pytest .mark .parametrize (
162- ("cli_args" , "inputs" , "env" , "template_ctx" , "exception" , "message" ),
163- [
164- (
165- ["-LDoesNotExist" , "-c" , "print(str(server.socket_name))" ],
166- [],
167- {},
168- {},
169- subprocess .CalledProcessError ,
170- r".*DoesNotExist.*" ,
171- ),
172- (
173- [
174- "-L{SOCKET_NAME}" ,
175- "nonexistent_session" ,
176- "-c" ,
177- "print(str(server.socket_name))" ,
178- ],
179- [],
180- {},
181- {"session_name" : "nonexistent_session" },
182- exc .TmuxpException ,
183- "Session not found: nonexistent_session" ,
184- ),
185- (
186- [
187- "-L{SOCKET_NAME}" ,
188- "{SESSION_NAME}" ,
189- "nonexistent_window" ,
190- "-c" ,
191- "print(str(server.socket_name))" ,
192- ],
193- [],
194- {},
195- {"window_name" : "nonexistent_window" },
196- exc .TmuxpException ,
197- "Window not found: {WINDOW_NAME}" ,
198- ),
199- ],
216+ list (CLIShellTargetMissingFixture ._fields ),
217+ TEST_SHELL_TARGET_MISSING_FIXTURES ,
218+ ids = [test .test_id for test in TEST_SHELL_TARGET_MISSING_FIXTURES ],
200219)
201220def test_shell_target_missing (
202221 cli_cmd : list [str ],
222+ test_id : str ,
203223 cli_args : list [str ],
204224 inputs : list [t .Any ],
205225 env : dict [t .Any , t .Any ],
@@ -245,41 +265,52 @@ def test_shell_target_missing(
245265 assert message .format (** template_ctx ) in result .out
246266
247267
268+ class CLIShellInteractiveFixture (t .NamedTuple ):
269+ """Test fixture for tmuxp shell interactive tests."""
270+
271+ test_id : str
272+ cli_args : list [str ]
273+ inputs : list [t .Any ]
274+ env : dict [str , str ]
275+ message : str
276+
277+
278+ TEST_SHELL_INTERACTIVE_FIXTURES : list [CLIShellInteractiveFixture ] = [
279+ CLIShellInteractiveFixture (
280+ test_id = "basic_interactive" ,
281+ cli_args = [
282+ "-L{SOCKET_NAME}" ,
283+ ],
284+ inputs = [],
285+ env = {},
286+ message = "(InteractiveConsole)" ,
287+ ),
288+ CLIShellInteractiveFixture (
289+ test_id = "interactive_with_pane_id" ,
290+ cli_args = [
291+ "-L{SOCKET_NAME}" ,
292+ ],
293+ inputs = [],
294+ env = {"PANE_ID" : "{PANE_ID}" },
295+ message = "(InteractiveConsole)" ,
296+ ),
297+ ]
298+
299+
248300@pytest .mark .parametrize (
249301 "cli_cmd" ,
250302 [
251- # ['shell'],
252- # ['shell', '--pdb'),
253303 ["shell" , "--code" ],
254- # ['shell', '--bpython'],
255- # ['shell', '--ptipython'],
256- # ['shell', '--ptpython'],
257- # ['shell', '--ipython'],
258304 ],
259305)
260306@pytest .mark .parametrize (
261- ("cli_args" , "inputs" , "env" , "message" ),
262- [
263- (
264- [
265- "-L{SOCKET_NAME}" ,
266- ],
267- [],
268- {},
269- "(InteractiveConsole)" ,
270- ),
271- (
272- [
273- "-L{SOCKET_NAME}" ,
274- ],
275- [],
276- {"PANE_ID" : "{PANE_ID}" },
277- "(InteractiveConsole)" ,
278- ),
279- ],
307+ list (CLIShellInteractiveFixture ._fields ),
308+ TEST_SHELL_INTERACTIVE_FIXTURES ,
309+ ids = [test .test_id for test in TEST_SHELL_INTERACTIVE_FIXTURES ],
280310)
281311def test_shell_interactive (
282312 cli_cmd : list [str ],
313+ test_id : str ,
283314 cli_args : list [str ],
284315 inputs : list [t .Any ],
285316 env : dict [str , str ],
0 commit comments