Skip to content

Commit 20d15c2

Browse files
committed
Support comma-separated values for --image-format option
As documented in the command line help message. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 488cbdc commit 20d15c2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44

5+
import argparse
56
import itertools
67
import logging
78
import os
@@ -50,6 +51,15 @@
5051
CACHE_IMPORTED_VM = False
5152
assert CACHE_IMPORTED_VM in [True, False]
5253

54+
class SplitCommaAction(argparse.Action):
55+
def __call__(self, parser, namespace, values, option_string=None):
56+
items = getattr(namespace, self.dest, None)
57+
if items is None:
58+
items = []
59+
if isinstance(values, str):
60+
items.extend([v.strip() for v in values.split(",") if v.strip()])
61+
setattr(namespace, self.dest, items)
62+
5363
# pytest hooks
5464

5565
def pytest_addoption(parser: pytest.Parser) -> None:
@@ -99,7 +109,7 @@ def pytest_addoption(parser: pytest.Parser) -> None:
99109
)
100110
parser.addoption(
101111
"--image-format",
102-
action="append",
112+
action=SplitCommaAction,
103113
default=[],
104114
help="Format of VDI to execute tests on."
105115
"Example: vhd,qcow2"

0 commit comments

Comments
 (0)