[elbe-devel] [PATCH 7/9] tests: test_parselicence: migrate to run_elbe_subcommand
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Thu Jul 25 11:47:17 CEST 2024
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/tests/test_parselicence.py | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/elbepack/tests/test_parselicence.py b/elbepack/tests/test_parselicence.py
index 6f68c9012f31..1b71d547b045 100644
--- a/elbepack/tests/test_parselicence.py
+++ b/elbepack/tests/test_parselicence.py
@@ -2,10 +2,12 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2024 Linutronix GmbH
+import contextlib
+import io
import pathlib
import re
-from elbepack.directories import run_elbe
+from elbepack.directories import run_elbe_subcommand
here = pathlib.Path(__file__).parent
@@ -19,15 +21,16 @@ def _replace_changing_spdx_data(s):
def test_parselicence(tmp_path):
xml_output = tmp_path.joinpath('licences.xml')
spdx_output = tmp_path.joinpath('licences.spdx')
- ps = run_elbe([
- 'parselicence',
- '--mapping', here.joinpath('cyclonedx', 'example-mapping.xml'),
- '--output', xml_output,
- '--tvout', spdx_output,
- here.joinpath('cyclonedx', 'build-simple-example', 'licence-target.xml'),
- ], check=True, capture_output=True)
-
- assert ps.stdout == b'statistics:\nnum:156 mr:137 hr:3 err_pkg:99\n'
+ with contextlib.redirect_stdout(io.StringIO()) as stdout:
+ run_elbe_subcommand([
+ 'parselicence',
+ '--mapping', here.joinpath('cyclonedx', 'example-mapping.xml'),
+ '--output', xml_output,
+ '--tvout', spdx_output,
+ here.joinpath('cyclonedx', 'build-simple-example', 'licence-target.xml'),
+ ])
+
+ assert stdout.getvalue() == 'statistics:\nnum:156 mr:137 hr:3 err_pkg:99\n'
xml_reference = here.joinpath('test_parselicence_reference.xml')
assert xml_output.read_text() == xml_reference.read_text()
--
2.45.2
More information about the elbe-devel
mailing list