[elbe-devel] [PATCH 05/11] elbepack: test_xml: execute initvm subcommand with correct arguments
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Thu Aug 8 11:38:16 CEST 2024
"elbe initvm" subcommands require various arguments to work correctly in
all cases. As only the "initvm" fixture knows how the initvm was set up,
introduce a function that can be used by the tests themselves to add the
necessary arguments.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/tests/test_xml.py | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index e4aae3593d64..9bf3816502e7 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -18,18 +18,21 @@ here = pathlib.Path(__file__).parent
@pytest.fixture(scope='module')
def initvm(tmp_path_factory, request):
+ initvm_dir = tmp_path_factory.mktemp('initvm-') / 'initvm'
+
+ def initvm_func(subcmd, *args):
+ run_elbe_subcommand(['initvm', subcmd, '--directory', initvm_dir, *args])
+
if request.config.getoption('--elbe-use-existing-initvm'):
- yield
+ yield initvm_func
return
- initvm_dir = tmp_path_factory.mktemp('initvm-') / 'initvm'
-
- run_elbe_subcommand(['initvm', 'create', '--fail-on-warning', '--directory', initvm_dir])
+ initvm_func('create', '--fail-on-warning')
- yield
+ yield initvm_func
with contextlib.suppress(Exception):
- run_elbe_subcommand(['initvm', 'destroy', '--directory', initvm_dir])
+ initvm_func('destroy')
def _delete_project(uuid):
@@ -42,12 +45,12 @@ def simple_build(request, initvm, tmp_path_factory):
build_dir = tmp_path_factory.mktemp('build_dir')
prj = build_dir / 'uuid.prj'
- run_elbe_subcommand([
- 'initvm', 'submit', request.param,
+ initvm(
+ 'submit', request.param,
'--output', build_dir,
'--keep-files', '--build-sdk',
'--writeproject', prj,
- ])
+ )
uuid = prj.read_text()
--
2.46.0
More information about the elbe-devel
mailing list