Browse Source

tools/qvm-create: fix handling invalid label

Marek Marczykowski-Górecki 5 years ago
parent
commit
5078d75aa3
2 changed files with 11 additions and 1 deletions
  1. 10 0
      qubesadmin/tests/tools/qvm_create.py
  2. 1 1
      qubesadmin/tools/qvm_create.py

+ 10 - 0
qubesadmin/tests/tools/qvm_create.py

@@ -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()
+

+ 1 - 1
qubesadmin/tools/qvm_create.py

@@ -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)