@@ -1099,131 +1099,143 @@ def test_find_current_active_pane(
1099
1099
assert builder .find_current_attached_session () == second_session
1100
1100
1101
1101
1102
- @pytest .mark .parametrize (
1103
- ("yaml" , "output" , "should_see" ),
1104
- [
1105
- (
1106
- textwrap .dedent (
1107
- """
1102
+ class WorkspaceEnterFixture (t .NamedTuple ):
1103
+ """Test fixture for workspace enter behavior verification."""
1104
+
1105
+ test_id : str
1106
+ yaml : str
1107
+ output : str
1108
+ should_see : bool
1109
+
1110
+
1111
+ WORKSPACE_ENTER_FIXTURES : list [WorkspaceEnterFixture ] = [
1112
+ WorkspaceEnterFixture (
1113
+ test_id = "pane_enter_false_shortform" ,
1114
+ yaml = textwrap .dedent (
1115
+ """
1108
1116
session_name: Should not execute
1109
1117
windows:
1110
1118
- panes:
1111
1119
- shell_command: echo "___$((1 + 3))___"
1112
1120
enter: false
1113
1121
""" ,
1114
- ),
1115
- "___4___" ,
1116
- False ,
1117
1122
),
1118
- (
1119
- textwrap .dedent (
1120
- """
1123
+ output = "___4___" ,
1124
+ should_see = False ,
1125
+ ),
1126
+ WorkspaceEnterFixture (
1127
+ test_id = "pane_enter_false_longform" ,
1128
+ yaml = textwrap .dedent (
1129
+ """
1121
1130
session_name: Should not execute
1122
1131
windows:
1123
1132
- panes:
1124
1133
- shell_command:
1125
1134
- echo "___$((1 + 3))___"
1126
1135
enter: false
1127
1136
""" ,
1128
- ),
1129
- "___4___" ,
1130
- False ,
1131
1137
),
1132
- (
1133
- textwrap .dedent (
1134
- """
1138
+ output = "___4___" ,
1139
+ should_see = False ,
1140
+ ),
1141
+ WorkspaceEnterFixture (
1142
+ test_id = "pane_enter_default_shortform" ,
1143
+ yaml = textwrap .dedent (
1144
+ """
1135
1145
session_name: Should execute
1136
1146
windows:
1137
1147
- panes:
1138
1148
- shell_command: echo "___$((1 + 3))___"
1139
1149
""" ,
1140
- ),
1141
- "___4___" ,
1142
- True ,
1143
1150
),
1144
- (
1145
- textwrap .dedent (
1146
- """
1151
+ output = "___4___" ,
1152
+ should_see = True ,
1153
+ ),
1154
+ WorkspaceEnterFixture (
1155
+ test_id = "pane_enter_default_longform" ,
1156
+ yaml = textwrap .dedent (
1157
+ """
1147
1158
session_name: Should execute
1148
1159
windows:
1149
1160
- panes:
1150
1161
- shell_command:
1151
1162
- echo "___$((1 + 3))___"
1152
1163
""" ,
1153
- ),
1154
- "___4___" ,
1155
- True ,
1156
1164
),
1157
- (
1158
- textwrap .dedent (
1159
- """
1165
+ output = "___4___" ,
1166
+ should_see = True ,
1167
+ ),
1168
+ WorkspaceEnterFixture (
1169
+ test_id = "pane_command_enter_false_shortform" ,
1170
+ yaml = textwrap .dedent (
1171
+ """
1160
1172
session_name: Should not execute
1161
1173
windows:
1162
1174
- panes:
1163
1175
- shell_command:
1164
1176
- cmd: echo "___$((1 + 3))___"
1165
1177
enter: false
1166
1178
""" ,
1167
- ),
1168
- "___4___" ,
1169
- False ,
1170
1179
),
1171
- ( # NOQA: PT014 RUF100
1172
- textwrap .dedent (
1173
- """
1180
+ output = "___4___" ,
1181
+ should_see = False ,
1182
+ ),
1183
+ WorkspaceEnterFixture ( # NOQA: PT014 RUF100
1184
+ test_id = "pane_command_enter_false_longform" ,
1185
+ yaml = textwrap .dedent (
1186
+ """
1174
1187
session_name: Should not execute
1175
1188
windows:
1176
1189
- panes:
1177
1190
- shell_command:
1178
1191
- cmd: echo "___$((1 + 3))___"
1179
1192
enter: false
1180
1193
""" ,
1181
- ),
1182
- "___4___" ,
1183
- False ,
1184
1194
),
1185
- ( # NOQA: PT014 RUF100
1186
- textwrap .dedent (
1187
- """
1195
+ output = "___4___" ,
1196
+ should_see = False ,
1197
+ ),
1198
+ WorkspaceEnterFixture ( # NOQA: PT014 RUF100
1199
+ test_id = "pane_command_enter_default_shortform" ,
1200
+ yaml = textwrap .dedent (
1201
+ """
1188
1202
session_name: Should execute
1189
1203
windows:
1190
1204
- panes:
1191
1205
- shell_command: echo "___$((1 + 3))___"
1192
1206
""" ,
1193
- ),
1194
- "___4___" ,
1195
- True ,
1196
1207
),
1197
- (
1198
- textwrap .dedent (
1199
- """
1208
+ output = "___4___" ,
1209
+ should_see = True ,
1210
+ ),
1211
+ WorkspaceEnterFixture (
1212
+ test_id = "pane_command_enter_default_longform" ,
1213
+ yaml = textwrap .dedent (
1214
+ """
1200
1215
session_name: Should execute
1201
1216
windows:
1202
1217
- panes:
1203
1218
- shell_command:
1204
1219
- cmd: echo "other command"
1205
1220
- cmd: echo "___$((1 + 3))___"
1206
1221
""" ,
1207
- ),
1208
- "___4___" ,
1209
- True ,
1210
1222
),
1211
- ],
1212
- ids = [
1213
- "pane_enter_false_shortform" ,
1214
- "pane_enter_false_longform" ,
1215
- "pane_enter_default_shortform" ,
1216
- "pane_enter_default_longform" ,
1217
- "pane_command_enter_false_shortform" ,
1218
- "pane_command_enter_false_longform" ,
1219
- "pane_command_enter_default_shortform" ,
1220
- "pane_command_enter_default_longform" ,
1221
- ],
1223
+ output = "___4___" ,
1224
+ should_see = True ,
1225
+ ),
1226
+ ]
1227
+
1228
+
1229
+ @pytest .mark .parametrize (
1230
+ list (WorkspaceEnterFixture ._fields ),
1231
+ WORKSPACE_ENTER_FIXTURES ,
1232
+ ids = [test .test_id for test in WORKSPACE_ENTER_FIXTURES ],
1222
1233
)
1223
1234
def test_load_workspace_enter (
1224
1235
tmp_path : pathlib .Path ,
1225
1236
server : Server ,
1226
1237
monkeypatch : pytest .MonkeyPatch ,
1238
+ test_id : str ,
1227
1239
yaml : str ,
1228
1240
output : str ,
1229
1241
should_see : bool ,
@@ -1255,12 +1267,20 @@ def fn() -> bool:
1255
1267
), f"Should{ ' ' if should_see else 'not ' } output in captured pane"
1256
1268
1257
1269
1258
- @pytest .mark .parametrize (
1259
- ("yaml" , "sleep" , "output" ),
1260
- [
1261
- (
1262
- textwrap .dedent (
1263
- """
1270
+ class WorkspaceSleepFixture (t .NamedTuple ):
1271
+ """Test fixture for workspace sleep behavior verification."""
1272
+
1273
+ test_id : str
1274
+ yaml : str
1275
+ sleep : float
1276
+ output : str
1277
+
1278
+
1279
+ WORKSPACE_SLEEP_FIXTURES : list [WorkspaceSleepFixture ] = [
1280
+ WorkspaceSleepFixture (
1281
+ test_id = "command_level_sleep_shortform" ,
1282
+ yaml = textwrap .dedent (
1283
+ """
1264
1284
session_name: Should not execute
1265
1285
windows:
1266
1286
- panes:
@@ -1270,13 +1290,14 @@ def fn() -> bool:
1270
1290
- cmd: echo "___$((1 + 3))___"
1271
1291
sleep_before: .35
1272
1292
""" ,
1273
- ),
1274
- 0.5 ,
1275
- "___4___" ,
1276
1293
),
1277
- (
1278
- textwrap .dedent (
1279
- """
1294
+ sleep = 0.5 ,
1295
+ output = "___4___" ,
1296
+ ),
1297
+ WorkspaceSleepFixture (
1298
+ test_id = "command_level_pane_sleep_longform" ,
1299
+ yaml = textwrap .dedent (
1300
+ """
1280
1301
session_name: Should not execute
1281
1302
windows:
1282
1303
- panes:
@@ -1286,41 +1307,44 @@ def fn() -> bool:
1286
1307
- cmd: echo "___$((1 + 3))___"
1287
1308
sleep_before: .25
1288
1309
""" ,
1289
- ),
1290
- 1.25 ,
1291
- "___4___" ,
1292
1310
),
1293
- (
1294
- textwrap .dedent (
1295
- """
1311
+ sleep = 1.25 ,
1312
+ output = "___4___" ,
1313
+ ),
1314
+ WorkspaceSleepFixture (
1315
+ test_id = "pane_sleep_shortform" ,
1316
+ yaml = textwrap .dedent (
1317
+ """
1296
1318
session_name: Should not execute
1297
1319
windows:
1298
1320
- panes:
1299
1321
- shell_command:
1300
1322
- cmd: echo "___$((1 + 3))___"
1301
1323
sleep_before: .5
1302
1324
""" ,
1303
- ),
1304
- 0.5 ,
1305
- "___4___" ,
1306
1325
),
1307
- (
1308
- textwrap .dedent (
1309
- """
1326
+ sleep = 0.5 ,
1327
+ output = "___4___" ,
1328
+ ),
1329
+ WorkspaceSleepFixture (
1330
+ test_id = "pane_sleep_longform" ,
1331
+ yaml = textwrap .dedent (
1332
+ """
1310
1333
session_name: Should not execute
1311
1334
windows:
1312
1335
- panes:
1313
1336
- shell_command:
1314
1337
- cmd: echo "___$((1 + 3))___"
1315
1338
sleep_before: 1
1316
1339
""" ,
1317
- ),
1318
- 1 ,
1319
- "___4___" ,
1320
1340
),
1321
- (
1322
- textwrap .dedent (
1323
- """
1341
+ sleep = 1 ,
1342
+ output = "___4___" ,
1343
+ ),
1344
+ WorkspaceSleepFixture (
1345
+ test_id = "shell_before_before_command_level" ,
1346
+ yaml = textwrap .dedent (
1347
+ """
1324
1348
session_name: Should not execute
1325
1349
shell_command_before:
1326
1350
- cmd: echo "sleeping before"
@@ -1329,26 +1353,26 @@ def fn() -> bool:
1329
1353
- panes:
1330
1354
- echo "___$((1 + 3))___"
1331
1355
""" ,
1332
- ),
1333
- 0.5 ,
1334
- "___4___" ,
1335
1356
),
1336
- ],
1337
- ids = [
1338
- "command_level_sleep_shortform" ,
1339
- "command_level_pane_sleep_longform" ,
1340
- "pane_sleep_shortform" ,
1341
- "pane_sleep_longform" ,
1342
- "shell_before_before_command_level" ,
1343
- ],
1357
+ sleep = 0.5 ,
1358
+ output = "___4___" ,
1359
+ ),
1360
+ ]
1361
+
1362
+
1363
+ @pytest .mark .parametrize (
1364
+ list (WorkspaceSleepFixture ._fields ),
1365
+ WORKSPACE_SLEEP_FIXTURES ,
1366
+ ids = [test .test_id for test in WORKSPACE_SLEEP_FIXTURES ],
1344
1367
)
1345
1368
@pytest .mark .flaky (reruns = 3 )
1346
1369
def test_load_workspace_sleep (
1347
1370
tmp_path : pathlib .Path ,
1348
1371
server : Server ,
1349
1372
monkeypatch : pytest .MonkeyPatch ,
1373
+ test_id : str ,
1350
1374
yaml : str ,
1351
- sleep : int ,
1375
+ sleep : float ,
1352
1376
output : str ,
1353
1377
) -> None :
1354
1378
"""Test sleep commands in tmuxp configuration."""
0 commit comments