Merge branch 'wip/laney/skip-memory-monitor-tests-if-dbusmock-is-too-old' into 'master'

tests: Skip GMemoryMonitor tests if the dbusmock template is not available

See merge request GNOME/glib!1296
This commit is contained in:
Iain Lane 2020-01-22 08:13:04 +00:00
commit b876325c5f
2 changed files with 12 additions and 4 deletions

View File

@ -38,8 +38,12 @@ class TestLowMemoryMonitor(dbusmock.DBusTestCase):
klass.dbus_con = klass.get_dbus(True) klass.dbus_con = klass.get_dbus(True)
def setUp(self): def setUp(self):
(self.p_mock, self.obj_lmm) = self.spawn_server_template( try:
'low_memory_monitor', {}, stdout=subprocess.PIPE) (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 # set log to nonblocking
flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL) flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL)
fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK) fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)

View File

@ -40,8 +40,12 @@ class TestLowMemoryMonitorPortal(dbusmock.DBusTestCase):
klass.start_session_bus() klass.start_session_bus()
def setUp(self): def setUp(self):
(self.p_mock, self.obj_lmm) = self.spawn_server_template( try:
'low_memory_monitor', {}, stdout=subprocess.PIPE) (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 # set log to nonblocking
flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL) flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL)
fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK) fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)