test/name-test: Be compatible with Python 3
authorSimon McVittie <smcv@collabora.com>
Fri, 7 Jul 2017 11:12:24 +0000 (12:12 +0100)
committerSimon McVittie <smcv@collabora.com>
Fri, 7 Jul 2017 12:14:38 +0000 (13:14 +0100)
configure.ac will detect PYTHON=python3 if there is no python
executable in the PATH.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101716
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
test/name-test/test-activation-forking.py
test/name-test/test-wait-for-echo.py

index f98537e..44bc1a6 100644 (file)
@@ -7,7 +7,7 @@ try:
     import dbus
     import dbus.mainloop.glib
 except:
-    print "Failed import, aborting test"
+    print("Failed import, aborting test")
     sys.exit(0)
 
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -23,7 +23,7 @@ i = dbus.Interface(o, 'org.freedesktop.TestSuite')
 
 # Start it up
 reply = i.Echo("hello world")
-print "TestSuiteForkingEchoService initial reply OK"
+print("TestSuiteForkingEchoService initial reply OK")
 
 def ignore(*args, **kwargs):
     pass
@@ -36,7 +36,7 @@ def on_forking_echo_owner_changed(name, old, new):
     global o
     global i
     if counter > 10:
-        print "Activated 10 times OK, TestSuiteForkingEchoService pass"
+        print("Activated 10 times OK, TestSuiteForkingEchoService pass")
         loop.quit()
         return
     counter += 1
@@ -52,7 +52,7 @@ i.Exit(reply_handler=ignore, error_handler=ignore)
 
 def check_counter():
     if counter == 0:
-        print "Failed to get NameOwnerChanged for TestSuiteForkingEchoService"
+        print("Failed to get NameOwnerChanged for TestSuiteForkingEchoService")
         sys.exit(1)
 GObject.timeout_add(15000, check_counter)
 
index 49ecbb4..d1b9e0c 100755 (executable)
@@ -7,7 +7,7 @@ try:
     import dbus.mainloop.glib
     from gi.repository import GObject
 except:
-    print "Failed import, aborting test"
+    print("Failed import, aborting test")
     sys.exit(0)
 
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -16,7 +16,7 @@ loop = GObject.MainLoop()
 exitcode = 0
 
 def handle_noreceipt():
-    print "Failed to get signal"
+    print("Failed to get signal")
     global exitcode
     exitcode = 1
     loop.quit()
@@ -26,7 +26,7 @@ GObject.timeout_add(7000, handle_noreceipt)
 bus = dbus.SessionBus()
 
 def sighandler(*args, **kwargs):
-    print "got signal"
+    print("got signal")
     loop.quit()   
 
 bus.add_signal_receiver(sighandler, dbus_interface='org.freedesktop.TestSuite', signal_name='Foo')