@@ -226,8 +226,11 @@ def local_sr_on_hostB1(hostB1):
226
226
yield sr
227
227
228
228
@pytest .fixture (scope = 'session' )
229
- def sr_disk (request , host ):
230
- disk = request .param
229
+ def sr_disk (pytestconfig , host ):
230
+ disks = pytestconfig .getoption ("sr_disk" )
231
+ if len (disks ) != 1 :
232
+ pytest .fail ("This test requires exactly one --sr-disk parameter" )
233
+ disk = disks [0 ]
231
234
if disk == "auto" :
232
235
logging .info (">> Check for the presence of a free disk device on the master host" )
233
236
disks = host .available_disks ()
@@ -241,8 +244,11 @@ def sr_disk(request, host):
241
244
yield disk
242
245
243
246
@pytest .fixture (scope = 'session' )
244
- def sr_disk_4k (request , host ):
245
- disk = request .param
247
+ def sr_disk_4k (pytestconfig , host ):
248
+ disks = pytestconfig .getoption ("sr_disk_4k" )
249
+ if len (disks ) != 1 :
250
+ pytest .fail ("This test requires exactly one --sr-disks-4k parameter" )
251
+ disk = disks [0 ]
246
252
if disk == "auto" :
247
253
logging .info (">> Check for the presence of a free 4KiB block device on the master host" )
248
254
disks = host .available_disks (4096 )
@@ -257,7 +263,10 @@ def sr_disk_4k(request, host):
257
263
258
264
@pytest .fixture (scope = 'session' )
259
265
def sr_disk_for_all_hosts (request , host ):
260
- disk = request .param
266
+ disks = pytestconfig .getoption ("sr_disk" )
267
+ if len (disks ) != 1 :
268
+ pytest .fail ("This test requires exactly one --sr-disk parameter" )
269
+ disk = disks [0 ]
261
270
master_disks = host .available_disks ()
262
271
assert len (master_disks ) > 0 , "a free disk device is required on the master host"
263
272
@@ -458,15 +467,6 @@ def pytest_generate_tests(metafunc):
458
467
if "second_network" in metafunc .fixturenames :
459
468
second_network = metafunc .config .getoption ("second_network" )
460
469
metafunc .parametrize ("second_network" , [second_network ], indirect = True , scope = "session" )
461
- if "sr_disk" in metafunc .fixturenames :
462
- disk = metafunc .config .getoption ("sr_disk" )
463
- metafunc .parametrize ("sr_disk" , disk , indirect = True , scope = "session" )
464
- if "sr_disk_4k" in metafunc .fixturenames :
465
- disk = metafunc .config .getoption ("sr_disk_4k" )
466
- metafunc .parametrize ("sr_disk_4k" , disk , indirect = True , scope = "session" )
467
- if "sr_disk_for_all_hosts" in metafunc .fixturenames :
468
- disk = metafunc .config .getoption ("sr_disk" )
469
- metafunc .parametrize ("sr_disk_for_all_hosts" , disk , indirect = True , scope = "session" )
470
470
471
471
def pytest_collection_modifyitems (items , config ):
472
472
# Automatically mark tests based on fixtures they require.
0 commit comments