@@ -46,8 +46,8 @@ def test_no_vnc_change_password(self):
self.assertEqual(set_password_response['error']['desc'],
'Could not set password')
- def test_change_password_requires_a_password(self):
- self.vm.add_args('-nodefaults', '-S', '-vnc', ':0')
+ def do_test_change_password_requires_a_password(self, port):
+ self.vm.add_args('-nodefaults', '-S', '-vnc', f':{port - 5900}')
self.vm.launch()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
set_password_response = self.vm.qmp('change-vnc-password',
@@ -58,13 +58,24 @@ def test_change_password_requires_a_password(self):
self.assertEqual(set_password_response['error']['desc'],
'Could not set password')
- def test_change_password(self):
- self.vm.add_args('-nodefaults', '-S', '-vnc', ':0,password=on')
+ def test_change_password_requires_a_password(self):
+ with Ports() as ports:
+ port = ports.find_free_port()
+ self.do_test_change_password_requires_a_password(port)
+
+ def do_test_change_password(self, port):
+ self.vm.add_args('-nodefaults', '-S',
+ '-vnc', f':{port - 5900},password=on')
self.vm.launch()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
self.vm.cmd('change-vnc-password',
password='new_password')
+ def test_change_password(self):
+ with Ports() as ports:
+ port = ports.find_free_port()
+ self.do_test_change_password(port)
+
def do_test_change_listen(self, a, b, c):
self.assertFalse(check_connect(a))
self.assertFalse(check_connect(b))
Two tests here are using the hard-coded VNC port :0 ... if there is already a QEMU or other program running that is using this port, the tests will be failing. Let's better detect a free port for these tests and use that one instead. Signed-off-by: Thomas Huth <thuth@redhat.com> --- tests/functional/test_vnc.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)