[virt-tools-list] [PATCH 01/10] uitests: Improve error message caused by another virt-manager being open

Povilas Kanapickas povilas at radix.lt
Sat Sep 1 22:17:21 UTC 2018


If an instance of virt-manager is open when running UI tests, they will
reuse it and will fail on the first action or check with completely
non-descriptive message. We can catch errors when initially acquiring
the window and provide a better error message.

Signed-off-by: Povilas Kanapickas <povilas at radix.lt>
---
 tests/uitests/utils.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/uitests/utils.py b/tests/uitests/utils.py
index b9c3c62c..c701d330 100644
--- a/tests/uitests/utils.py
+++ b/tests/uitests/utils.py
@@ -22,6 +22,7 @@ class UITestCase(unittest.TestCase):
     """
     def setUp(self):
         self.app = VMMDogtailApp(tests.utils.URIs.test_full)
+
     def tearDown(self):
         self.app.stop()
 
@@ -364,8 +365,15 @@ class VMMDogtailApp(object):
         cmd += extra_opts
 
         self._proc = subprocess.Popen(cmd, stdout=stdout, stderr=stderr)
-        self._root = dogtail.tree.root.application("virt-manager")
-        self._topwin = self._root.find(None, "(frame|dialog|alert)")
+
+        try:
+            self._root = dogtail.tree.root.application("virt-manager")
+            self._topwin = self._root.find(None, "(frame|dialog|alert)")
+        except RuntimeError:
+            msg = "Could not access the top virt-manager window. Maybe " \
+                "another instance of virt-manager is active? Please close it " \
+                "before running tests"
+            raise RuntimeError(msg)
 
     def stop(self):
         """
-- 
2.17.1





More information about the virt-tools-list mailing list