@@ -104,6 +104,92 @@ class CLIShellFixture(t.NamedTuple):
104
104
]
105
105
106
106
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
+
161
+ class CLIShellInteractiveFixture (t .NamedTuple ):
162
+ """Test fixture for tmuxp shell interactive tests."""
163
+
164
+ test_id : str
165
+ cli_args : list [str ]
166
+ inputs : list [t .Any ]
167
+ env : dict [str , str ]
168
+ message : str
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