mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-18 11:41:58 +02:00
gio/tests/memory-monitor-*.py.in: skip if 3rd party modules not available
The GIO tests memory-monitor-dbus and memory-monitor-portal use a number of third party Python modules that may not be present when running the test case. Instead of failing due to missing imports, catch the ImportError and mock a test case that skips. This can't use the usual unittest.skip logic because the test case class itself uses a 3rd party module. Closes #2083.
This commit is contained in:
parent
de8708cd95
commit
2709d5e1bb
@ -14,15 +14,18 @@ __license__ = 'LGPL 3+'
|
|||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import dbus
|
|
||||||
import dbus.mainloop.glib
|
|
||||||
import dbusmock
|
|
||||||
import fcntl
|
import fcntl
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import taptestrunner
|
import taptestrunner
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Do all non-standard imports here so we can skip the tests if any
|
||||||
|
# needed packages are not available.
|
||||||
|
import dbus
|
||||||
|
import dbus.mainloop.glib
|
||||||
|
import dbusmock
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
|
|
||||||
@ -98,6 +101,11 @@ class TestLowMemoryMonitor(dbusmock.DBusTestCase):
|
|||||||
self.main_context.iteration(False)
|
self.main_context.iteration(False)
|
||||||
self.assertEqual(self.last_warning, 255)
|
self.assertEqual(self.last_warning, 255)
|
||||||
|
|
||||||
|
except ImportError as e:
|
||||||
|
@unittest.skip("Cannot import %s" % e.name)
|
||||||
|
class TestLowMemoryMonitor(unittest.TestCase):
|
||||||
|
def test_low_memory_warning_signal(self):
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(testRunner=taptestrunner.TAPTestRunner())
|
unittest.main(testRunner=taptestrunner.TAPTestRunner())
|
||||||
|
@ -14,15 +14,18 @@ __license__ = 'LGPL 3+'
|
|||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import dbus
|
|
||||||
import dbus.mainloop.glib
|
|
||||||
import dbusmock
|
|
||||||
import fcntl
|
import fcntl
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import taptestrunner
|
import taptestrunner
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Do all non-standard imports here so we can skip the tests if any
|
||||||
|
# needed packages are not available.
|
||||||
|
import dbus
|
||||||
|
import dbus.mainloop.glib
|
||||||
|
import dbusmock
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
|
|
||||||
@ -114,6 +117,11 @@ class TestLowMemoryMonitorPortal(dbusmock.DBusTestCase):
|
|||||||
self.main_context.iteration(False)
|
self.main_context.iteration(False)
|
||||||
self.assertEqual(self.last_warning, 255)
|
self.assertEqual(self.last_warning, 255)
|
||||||
|
|
||||||
|
except ImportError as e:
|
||||||
|
@unittest.skip("Cannot import %s" % e.name)
|
||||||
|
class TestLowMemoryMonitorPortal(unittest.TestCase):
|
||||||
|
def test_low_memory_warning_portal_signal(self):
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(testRunner=taptestrunner.TAPTestRunner())
|
unittest.main(testRunner=taptestrunner.TAPTestRunner())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user