[glib/wip/laney/skip-memory-monitor-tests-if-dbusmock-is-too-old] tests: Skip GMemoryMonitor tests if the dbusmock template is not available



commit 8285ddc335e6d1efaf45d6d884b055952a6fb22e
Author: Iain Lane <iain lane canonical com>
Date:   Wed Dec 18 09:41:31 2019 +0000

    tests: Skip GMemoryMonitor tests if the dbusmock template is not available
    
    This template is not currently in any released version of dbusmock.

 gio/tests/memory-monitor-dbus.py.in   | 8 ++++++--
 gio/tests/memory-monitor-portal.py.in | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gio/tests/memory-monitor-dbus.py.in b/gio/tests/memory-monitor-dbus.py.in
index b1bae7c40..89906f482 100755
--- a/gio/tests/memory-monitor-dbus.py.in
+++ b/gio/tests/memory-monitor-dbus.py.in
@@ -38,8 +38,12 @@ class TestLowMemoryMonitor(dbusmock.DBusTestCase):
         klass.dbus_con = klass.get_dbus(True)
 
     def setUp(self):
-        (self.p_mock, self.obj_lmm) = self.spawn_server_template(
-            'low_memory_monitor', {}, stdout=subprocess.PIPE)
+        try:
+            (self.p_mock, self.obj_lmm) = self.spawn_server_template(
+                'low_memory_monitor', {}, stdout=subprocess.PIPE)
+        except ModuleNotFoundError:
+            raise unittest.SkipTest("Low memory monitor dbusmock template not "
+                                    "found. Requires dbusmock ≥ 0.18.4.")
         # set log to nonblocking
         flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL)
         fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
diff --git a/gio/tests/memory-monitor-portal.py.in b/gio/tests/memory-monitor-portal.py.in
index 35f546212..cd7d741b1 100755
--- a/gio/tests/memory-monitor-portal.py.in
+++ b/gio/tests/memory-monitor-portal.py.in
@@ -40,8 +40,12 @@ class TestLowMemoryMonitorPortal(dbusmock.DBusTestCase):
         klass.start_session_bus()
 
     def setUp(self):
-        (self.p_mock, self.obj_lmm) = self.spawn_server_template(
-            'low_memory_monitor', {}, stdout=subprocess.PIPE)
+        try:
+            (self.p_mock, self.obj_lmm) = self.spawn_server_template(
+                'low_memory_monitor', {}, stdout=subprocess.PIPE)
+        except ModuleNotFoundError:
+            raise unittest.SkipTest("Low memory monitor dbusmock template not "
+                                    "found. Requires dbusmock ≥ 0.18.4.")
         # set log to nonblocking
         flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL)
         fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]