summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2020-11-23 10:36:21 +0000
committerSimon McVittie <smcv@collabora.com>2020-11-23 10:42:41 +0000
commitb356bba0644be3f120a8b9561d178b5d98cd7dcf (patch)
tree4bb90a6de7cdf9415c82ea54ec1223d034a89e57
parentcf9ec4e4f70d428b03757b2dd8e5894a1df49ad8 (diff)
downloaddbus-python-b356bba0644be3f120a8b9561d178b5d98cd7dcf.tar.gz
tests: Use gi.repository.GLib to avoid deprecation warnings
Back in the days of PyGTK, there was only the gobject module, containing bindings for both GLib and GObject. This is no longer the case. Signed-off-by: Simon McVittie <smcv@collabora.com>
-rwxr-xr-xtest/cross-test-client.py6
-rwxr-xr-xtest/cross-test-server.py12
-rwxr-xr-xtest/test-client.py12
-rwxr-xr-xtest/test-p2p.py6
-rwxr-xr-xtest/test-service.py10
-rwxr-xr-xtest/test-signals.py16
6 files changed, 31 insertions, 31 deletions
diff --git a/test/cross-test-client.py b/test/cross-test-client.py
index c2da193..fe196ce 100755
--- a/test/cross-test-client.py
+++ b/test/cross-test-client.py
@@ -28,7 +28,7 @@ from __future__ import print_function, unicode_literals
import logging
try:
- from gi.repository import GObject as gobject
+ from gi.repository import GLib
except ImportError:
raise SystemExit(77)
@@ -415,9 +415,9 @@ if __name__ == '__main__':
# the Java cross test's interpretation is that the client should be
# at /Test too
client = Client(dbus.SessionBus(), '/Test')
- gobject.idle_add(client.run_client)
+ GLib.idle_add(client.run_client)
- loop = gobject.MainLoop()
+ loop = GLib.MainLoop()
logger.info("running...")
loop.run()
logger.info("main loop exited.")
diff --git a/test/cross-test-server.py b/test/cross-test-server.py
index e3edea2..3799937 100755
--- a/test/cross-test-server.py
+++ b/test/cross-test-server.py
@@ -28,7 +28,7 @@ from __future__ import print_function
import logging
try:
- from gi.repository import GObject as gobject
+ from gi.repository import GLib
except ImportError:
raise SystemExit(77)
@@ -283,9 +283,9 @@ class TestsImpl(dbus.service.Object):
assert isinstance(object, str)
logger.info('method/signal: client wants me to emit Triggered(%r) from %r', parameter, object)
tested_things.add(INTERFACE_TESTS + '.Trigger')
- gobject.idle_add(lambda: self.emit_Triggered_from(conn, object,
- parameter,
- reply_cb))
+ GLib.idle_add(lambda: self.emit_Triggered_from(conn, object,
+ parameter,
+ reply_cb))
def emit_Triggered_from(self, conn, object, parameter, reply_cb):
assert isinstance(object, str)
@@ -307,7 +307,7 @@ class TestsImpl(dbus.service.Object):
if x not in tested_things:
print('%s untested' % x)
logger.info('will quit when idle')
- gobject.idle_add(self._exit_fn)
+ GLib.idle_add(self._exit_fn)
class Server(SingleTestsImpl, TestsImpl, SignalTestsImpl):
@@ -325,7 +325,7 @@ class Server(SingleTestsImpl, TestsImpl, SignalTestsImpl):
if __name__ == '__main__':
bus = SessionBus()
bus_name = BusName(CROSS_TEST_BUS_NAME, bus=bus)
- loop = gobject.MainLoop()
+ loop = GLib.MainLoop()
obj = Server(bus_name, CROSS_TEST_PATH, loop.quit)
objects[CROSS_TEST_PATH] = obj
kwargs = {}
diff --git a/test/test-client.py b/test/test-client.py
index bc6a900..c905e6d 100755
--- a/test/test-client.py
+++ b/test/test-client.py
@@ -42,9 +42,9 @@ import dbus_test_utils
from dbus._compat import is_py2, is_py3
try:
- from gi.repository import GObject as gobject
+ from gi.repository import GLib
except ImportError:
- print('1..0 # SKIP cannot import GObject')
+ print('1..0 # SKIP cannot import GLib')
raise SystemExit(0)
logging.basicConfig()
@@ -203,7 +203,7 @@ class TestDBusBindings(unittest.TestCase):
def testNoReply(self):
failures = []
report = []
- main_loop = gobject.MainLoop()
+ main_loop = GLib.MainLoop()
unicode_type = (str if is_py3 else unicode)
def message_filter(conn, m):
@@ -256,7 +256,7 @@ class TestDBusBindings(unittest.TestCase):
print("\n********* Testing Async Calls ***********")
failures = []
- main_loop = gobject.MainLoop()
+ main_loop = GLib.MainLoop()
class async_check:
def __init__(self, test_controler, expected_result, do_exit, **kwargs):
@@ -574,7 +574,7 @@ class TestDBusBindings(unittest.TestCase):
dbus.Bus(private=True).close()
def testTimeoutAsyncClient(self):
- loop = gobject.MainLoop()
+ loop = GLib.MainLoop()
passes = []
fails = []
def correctly_returned():
@@ -685,7 +685,7 @@ class TestDBusPythonToGLibBindings(unittest.TestCase):
self.assertEqual(send_val, recv_val.object)
"""
if __name__ == '__main__':
- gobject.threads_init()
+ GLib.threads_init()
dbus.glib.init_threads()
dbus_test_utils.main()
diff --git a/test/test-p2p.py b/test/test-p2p.py
index b0d7ac0..06b9b43 100755
--- a/test/test-p2p.py
+++ b/test/test-p2p.py
@@ -40,9 +40,9 @@ import dbus_test_utils
from dbus._compat import is_py2
try:
- from gi.repository import GObject as gobject
+ from gi.repository import GLib
except ImportError:
- print('1..0 # SKIP cannot import GObject')
+ print('1..0 # SKIP cannot import GLib')
raise SystemExit(0)
logging.basicConfig()
@@ -123,7 +123,7 @@ class TestDBusBindings(unittest.TestCase):
if __name__ == '__main__':
- gobject.threads_init()
+ GLib.threads_init()
dbus.glib.init_threads()
dbus_test_utils.main()
diff --git a/test/test-service.py b/test/test-service.py
index 2799185..5440dfa 100755
--- a/test/test-service.py
+++ b/test/test-service.py
@@ -51,7 +51,7 @@ import dbus.glib
import random
from dbus.gi_service import ExportedGObject
-from gi.repository import GObject
+from gi.repository import GLib
from dbus._compat import is_py2, is_py3
@@ -295,8 +295,8 @@ class TestObject(dbus.service.Object, TestInterface):
def AsynchronousMethod(self, async_, fail, variant, return_cb, error_cb):
try:
if async_:
- GObject.timeout_add(500, self.AsynchronousMethod, False, fail,
- variant, return_cb, error_cb)
+ GLib.timeout_add(500, self.AsynchronousMethod, False, fail,
+ variant, return_cb, error_cb)
return
else:
if fail:
@@ -342,7 +342,7 @@ class TestObject(dbus.service.Object, TestInterface):
def return_from_async_wait():
return_cb()
return False
- GObject.timeout_add(500, return_from_async_wait)
+ GLib.timeout_add(500, return_from_async_wait)
@dbus.service.method(IFACE, in_signature='', out_signature='')
def RaiseValueError(self):
@@ -405,7 +405,7 @@ def main():
logger.info('making Fallback')
fallback_object = Fallback(session_bus)
logger.info('creating mainloop')
- loop = GObject.MainLoop()
+ loop = GLib.MainLoop()
logger.info('running')
loop.run()
logger.info('done')
diff --git a/test/test-signals.py b/test/test-signals.py
index 1e55f78..ed9ac4a 100755
--- a/test/test-signals.py
+++ b/test/test-signals.py
@@ -38,9 +38,9 @@ import dbus.service
import dbus_test_utils
try:
- from gi.repository import GObject as gobject
+ from gi.repository import GLib
except ImportError:
- print('1..0 # SKIP cannot import GObject')
+ print('1..0 # SKIP cannot import GLib')
raise SystemExit(0)
logging.basicConfig()
@@ -111,23 +111,23 @@ class TestSignals(unittest.TestCase):
path_keyword='path')
logger.info('Waiting for signal...')
iface.EmitSignal('SignalOneString', 0)
- source_id = gobject.timeout_add(1000, _timeout_handler)
+ source_id = GLib.timeout_add(1000, _timeout_handler)
main_loop.run()
if not result:
raise AssertionError('Signal did not arrive within 1 second')
logger.debug('Removing match')
match.remove()
- gobject.source_remove(source_id)
+ GLib.source_remove(source_id)
if test_removal:
self.in_test = name + '+removed'
logger.info('Testing %s', name)
result = []
iface.EmitSignal('SignalOneString', 0)
- source_id = gobject.timeout_add(1000, _rm_timeout_handler)
+ source_id = GLib.timeout_add(1000, _rm_timeout_handler)
main_loop.run()
if result:
raise AssertionError('Signal should not have arrived, but did')
- gobject.source_remove(source_id)
+ GLib.source_remove(source_id)
def testFallback(self):
self.signal_test_impl(self.fallback_iface, 'Fallback')
@@ -160,8 +160,8 @@ class TestSignals(unittest.TestCase):
self.signal_test_impl(self.iface_follow, 'RemovalAgain', True)
if __name__ == '__main__':
- main_loop = gobject.MainLoop()
- gobject.threads_init()
+ main_loop = GLib.MainLoop()
+ GLib.threads_init()
dbus.glib.init_threads()
logger.info('Starting unit test')