From 18c8fdb417edc5a5bed53956e91e6dded78bbf94 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Fri, 6 Jan 2023 12:00:00 +0100 Subject: [PATCH 1/2] Unit tests: Add simple pytest test for bugtool.disk_list() Signed-off-by: Bernhard Kaindl --- tests/unit/test_fs_funcs.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/test_fs_funcs.py b/tests/unit/test_fs_funcs.py index b3e781a0..21671d38 100644 --- a/tests/unit/test_fs_funcs.py +++ b/tests/unit/test_fs_funcs.py @@ -17,3 +17,8 @@ def test_read_inventory(bugtool, dom0_template): inventory = bugtool.readKeyValueFile(dom0_template + bugtool.XENSOURCE_INVENTORY) assert inventory["PRODUCT_VERSION"] == "8.3.0" + + +def test_disk_list(bugtool): + """Assert that the return value of disk_list() contains sda or nvme0n1""" + assert "sda" in bugtool.disk_list() or "nvme0n1" in bugtool.disk_list() From ad7afb7be71c309028b9f7010f7b2563b2f6db39 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Mon, 8 Jan 2024 12:00:00 +0100 Subject: [PATCH 2/2] xen-bugtool: Remove not used function prettyDict() Signed-off-by: Bernhard Kaindl --- xen-bugtool | 5 ----- 1 file changed, 5 deletions(-) diff --git a/xen-bugtool b/xen-bugtool index b193813b..bb315e8e 100755 --- a/xen-bugtool +++ b/xen-bugtool @@ -1993,11 +1993,6 @@ def capability(document, key): document.getElementsByTagName(CAP_XML_ROOT)[0].appendChild(el) -def prettyDict(d): - format = '%%-%ds: %%s' % max(map(len, [k for k, _ in d.items()])) - return '\n'.join([format % i for i in d.items()]) + '\n' - - def yes(prompt): yn = input(prompt)