Skip to content

Commit c641127

Browse files
committed
conftest: stop using a test parameter for sr_disk
Signed-off-by: Yann Dirson <[email protected]>
1 parent 5d5cd3e commit c641127

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

conftest.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,11 @@ def local_sr_on_hostB1(hostB1):
226226
yield sr
227227

228228
@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]
231234
if disk == "auto":
232235
logging.info(">> Check for the presence of a free disk device on the master host")
233236
disks = host.available_disks()
@@ -241,8 +244,11 @@ def sr_disk(request, host):
241244
yield disk
242245

243246
@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]
246252
if disk == "auto":
247253
logging.info(">> Check for the presence of a free 4KiB block device on the master host")
248254
disks = host.available_disks(4096)
@@ -257,7 +263,10 @@ def sr_disk_4k(request, host):
257263

258264
@pytest.fixture(scope='session')
259265
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]
261270
master_disks = host.available_disks()
262271
assert len(master_disks) > 0, "a free disk device is required on the master host"
263272

@@ -458,15 +467,6 @@ def pytest_generate_tests(metafunc):
458467
if "second_network" in metafunc.fixturenames:
459468
second_network = metafunc.config.getoption("second_network")
460469
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")
470470

471471
def pytest_collection_modifyitems(items, config):
472472
# Automatically mark tests based on fixtures they require.

0 commit comments

Comments
 (0)