curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #03702
[Merge] ~ogayot/curtin:get_partition_sfdisk_info-syntax-error into curtin:master
Olivier Gayot has proposed merging ~ogayot/curtin:get_partition_sfdisk_info-syntax-error into curtin:master.
Commit message:
block: fix string interpolation when building RuntimeError
The get_partition_sfdisk_info function means to raise a RuntimError if
the specified defice is not found in the sfdisk output. However, the
string interpolation does not work because of missing parens. As a
consequence, a TypeError exception is raised instead of the
RuntimeError.
LP: #2059414
Signed-off-by: Olivier Gayot <olivier.gayot@xxxxxxxxxxxxx>
Requested reviews:
curtin developers (curtin-dev)
Related bugs:
Bug #2059414 in curtin: "Syntax error on curtin/block/__init__.py#L317-L318"
https://bugs.launchpad.net/curtin/+bug/2059414
For more details, see:
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/474163
--
Your team curtin developers is requested to review the proposed merge of ~ogayot/curtin:get_partition_sfdisk_info-syntax-error into curtin:master.
diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
index 0de202a..b927695 100644
--- a/curtin/block/__init__.py
+++ b/curtin/block/__init__.py
@@ -315,7 +315,7 @@ def get_partition_sfdisk_info(devpath, sfdisk_info=None):
if os.path.realpath(part['node']) == os.path.realpath(devpath)]
if len(entry) != 1:
raise RuntimeError('Device %s not present in sfdisk dump:\n%s' %
- devpath, util.json_dumps(sfdisk_info))
+ (devpath, util.json_dumps(sfdisk_info)))
return entry.pop()
diff --git a/tests/unittests/test_block.py b/tests/unittests/test_block.py
index 2818fe4..9fcdb43 100644
--- a/tests/unittests/test_block.py
+++ b/tests/unittests/test_block.py
@@ -192,6 +192,11 @@ class TestBlock(CiTestCase):
m_exists.return_value = False
self.assertEqual(None, block.disk_to_byid_path('/dev/sdb'))
+ def test_get_partition_sfdisk_info__not_present(self):
+ with self.assertRaisesRegex(RuntimeError,
+ "not present in sfdisk dump"):
+ block.get_partition_sfdisk_info("/dev/sda1", {"partitions": []})
+
class TestSysBlockPath(CiTestCase):
@mock.patch("os.path.exists")
Follow ups