@@ -31,6 +31,28 @@ class CLIShellFixture(t.NamedTuple):
31
31
expected_output : str
32
32
33
33
34
+ class CLIShellTargetMissingFixture (t .NamedTuple ):
35
+ """Test fixture for tmuxp shell target missing tests."""
36
+
37
+ test_id : str
38
+ cli_args : list [str ]
39
+ inputs : list [t .Any ]
40
+ env : dict [t .Any , t .Any ]
41
+ template_ctx : dict [str , str ]
42
+ exception : type [exc .TmuxpException | subprocess .CalledProcessError ]
43
+ message : str
44
+
45
+
46
+ class CLIShellInteractiveFixture (t .NamedTuple ):
47
+ """Test fixture for tmuxp shell interactive tests."""
48
+
49
+ test_id : str
50
+ cli_args : list [str ]
51
+ inputs : list [t .Any ]
52
+ env : dict [str , str ]
53
+ message : str
54
+
55
+
34
56
TEST_SHELL_FIXTURES : list [CLIShellFixture ] = [
35
57
CLIShellFixture (
36
58
test_id = "print-socket-name" ,
@@ -104,6 +126,70 @@ class CLIShellFixture(t.NamedTuple):
104
126
]
105
127
106
128
129
+ TEST_SHELL_TARGET_MISSING_FIXTURES : list [CLIShellTargetMissingFixture ] = [
130
+ CLIShellTargetMissingFixture (
131
+ test_id = "nonexistent_socket" ,
132
+ cli_args = ["-LDoesNotExist" , "-c" , "print(str(server.socket_name))" ],
133
+ inputs = [],
134
+ env = {},
135
+ template_ctx = {},
136
+ exception = subprocess .CalledProcessError ,
137
+ message = r".*DoesNotExist.*" ,
138
+ ),
139
+ CLIShellTargetMissingFixture (
140
+ test_id = "nonexistent_session" ,
141
+ cli_args = [
142
+ "-L{SOCKET_NAME}" ,
143
+ "nonexistent_session" ,
144
+ "-c" ,
145
+ "print(str(server.socket_name))" ,
146
+ ],
147
+ inputs = [],
148
+ env = {},
149
+ template_ctx = {"session_name" : "nonexistent_session" },
150
+ exception = exc .TmuxpException ,
151
+ message = "Session not found: nonexistent_session" ,
152
+ ),
153
+ CLIShellTargetMissingFixture (
154
+ test_id = "nonexistent_window" ,
155
+ cli_args = [
156
+ "-L{SOCKET_NAME}" ,
157
+ "{SESSION_NAME}" ,
158
+ "nonexistent_window" ,
159
+ "-c" ,
160
+ "print(str(server.socket_name))" ,
161
+ ],
162
+ inputs = [],
163
+ env = {},
164
+ template_ctx = {"window_name" : "nonexistent_window" },
165
+ exception = exc .TmuxpException ,
166
+ message = "Window not found: {WINDOW_NAME}" ,
167
+ ),
168
+ ]
169
+
170
+
171
+ TEST_SHELL_INTERACTIVE_FIXTURES : list [CLIShellInteractiveFixture ] = [
172
+ CLIShellInteractiveFixture (
173
+ test_id = "basic_interactive" ,
174
+ cli_args = [
175
+ "-L{SOCKET_NAME}" ,
176
+ ],
177
+ inputs = [],
178
+ env = {},
179
+ message = "(InteractiveConsole)" ,
180
+ ),
181
+ CLIShellInteractiveFixture (
182
+ test_id = "interactive_with_pane_id" ,
183
+ cli_args = [
184
+ "-L{SOCKET_NAME}" ,
185
+ ],
186
+ inputs = [],
187
+ env = {"PANE_ID" : "{PANE_ID}" },
188
+ message = "(InteractiveConsole)" ,
189
+ ),
190
+ ]
191
+
192
+
107
193
@pytest .mark .parametrize ("cli_cmd" , [["shell" ], ["shell" , "--pdb" ]])
108
194
@pytest .mark .parametrize (
109
195
list (CLIShellFixture ._fields ),
@@ -159,47 +245,13 @@ def test_shell(
159
245
],
160
246
)
161
247
@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
- ],
248
+ list (CLIShellTargetMissingFixture ._fields ),
249
+ TEST_SHELL_TARGET_MISSING_FIXTURES ,
250
+ ids = [test .test_id for test in TEST_SHELL_TARGET_MISSING_FIXTURES ],
200
251
)
201
252
def test_shell_target_missing (
202
253
cli_cmd : list [str ],
254
+ test_id : str ,
203
255
cli_args : list [str ],
204
256
inputs : list [t .Any ],
205
257
env : dict [t .Any , t .Any ],
@@ -248,38 +300,17 @@ def test_shell_target_missing(
248
300
@pytest .mark .parametrize (
249
301
"cli_cmd" ,
250
302
[
251
- # ['shell'],
252
- # ['shell', '--pdb'),
253
303
["shell" , "--code" ],
254
- # ['shell', '--bpython'],
255
- # ['shell', '--ptipython'],
256
- # ['shell', '--ptpython'],
257
- # ['shell', '--ipython'],
258
304
],
259
305
)
260
306
@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 ],
280
310
)
281
311
def test_shell_interactive (
282
312
cli_cmd : list [str ],
313
+ test_id : str ,
283
314
cli_args : list [str ],
284
315
inputs : list [t .Any ],
285
316
env : dict [str , str ],
0 commit comments