tools/qvm-create: fix handling invalid label

This commit is contained in:
Marek Marczykowski-Górecki 2018-10-18 03:24:24 +02:00
parent 759fafea63
commit 5078d75aa3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 11 additions and 1 deletions

View File

@ -312,3 +312,13 @@ class TC_00_qvm_create(qubesadmin.tests.QubesTestCase):
app=self.app)
self.assertAllCalled()
def test_012_invalid_label(self):
self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \
b'0\x00red\nblue\n'
with self.assertRaises(SystemExit):
with qubesadmin.tests.tools.StderrBuffer() as stderr:
qubesadmin.tools.qvm_create.main(['-l', 'invalid', 'name'],
app=self.app)
self.assertIn('red, blue', stderr.getvalue())
self.assertAllCalled()

View File

@ -129,7 +129,7 @@ def main(args=None, app=None):
except KeyError:
parser.error('no such label: {!r}; available: {}'.format(
args.properties['label'],
', '.join(repr(l.name) for l in args.app.labels)))
', '.join(args.app.labels)))
try:
args.app.get_vm_class(args.cls)