From 283061b4190f2256149d789a0a164253d4f0086e Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 30 Jun 2020 11:08:32 +0000 Subject: [PATCH] [libcontentaction] Remove qt5-default dependency Not required, qt4->5 build handling removed from other build scripts a long time ago. --- data/gen-regexps | 6 +- data/regextest2.py | 8 +-- rpm/libcontentaction-qt5.spec | 9 ++- tests/applications/fixedparams.desktop | 2 +- tests/applications/uberexec.desktop | 2 +- tests/applications/uriprinter.desktop | 2 +- tests/cltool.py | 16 ++--- tests/gallery.py | 6 +- tests/launchme.desktop | 2 +- tests/servicemapper.py | 10 +-- tests/test-defaults.py | 28 ++++----- tests/test-desktop-launching.py | 16 ++--- tests/test-fixed-params.py | 10 +-- tests/test-invalid-defaults.py | 12 ++-- tests/test-invoking.py | 28 ++++----- tests/test-mimes.py | 32 +++++----- tests/test-regexps.py | 84 +++++++++++++------------- tests/test-servicefw-signals.py | 24 ++++---- tests/test-special-chars.py | 22 +++---- tests/uberprogram.py | 8 +-- 20 files changed, 163 insertions(+), 164 deletions(-) diff --git a/data/gen-regexps b/data/gen-regexps index f563794..c46b9cd 100755 --- a/data/gen-regexps +++ b/data/gen-regexps @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 # coding=UTF-8 # This program generates the complicated regular expressions used in @@ -49,8 +49,8 @@ def rx_opt (rx): return rx_repeat (rx, 0, 1) def rx_output (rx, name): - print("s/@%s@/%s/g\n" % (name, - rx.replace('\\', '\\\\').replace('/', '\\/').replace('"', '\"').replace('&', '\&'))) + print(("s/@%s@/%s/g\n" % (name, + rx.replace('\\', '\\\\').replace('/', '\\/').replace('"', '\"').replace('&', '\&')))) ## Phone numbers diff --git a/data/regextest2.py b/data/regextest2.py index 43b4a93..f796413 100644 --- a/data/regextest2.py +++ b/data/regextest2.py @@ -4,7 +4,7 @@ import functools # -# Note: unittest in python < 2.7 doesn't support expectedFailures +# Note: this was originally written with python2.7 unittest which doesn't support expectedFailures # def escape_for_shell (str): @@ -32,8 +32,8 @@ def regex_test (self): parts = self.__spec.split (self.__delimiter) text = "".join (parts) expected = [ parts[i] for i in range (1, len (parts), 2) ] - result = list (map (lambda m: m.group(0), re.finditer (self.__regex, text))) - self.assertEquals (result, expected) + result = list ([m.group(0) for m in re.finditer (self.__regex, text)]) + self.assertEqual (result, expected) class SystemRegexTest (unittest.TestCase): @@ -83,7 +83,7 @@ def regex_test (self): expected_result = expected.pop (0) - self.assertEquals (result[1:-1], expected_result, + self.assertEqual (result[1:-1], expected_result, "'%s' is not recognized properly " % (self.__spec) + "(matched '%s' instead of '%s')" % (result, expected_result) diff --git a/rpm/libcontentaction-qt5.spec b/rpm/libcontentaction-qt5.spec index 308dae8..5872a18 100644 --- a/rpm/libcontentaction-qt5.spec +++ b/rpm/libcontentaction-qt5.spec @@ -15,7 +15,7 @@ BuildRequires: pkgconfig(Qt5Test) BuildRequires: pkgconfig(Qt5Xml) BuildRequires: pkgconfig(Qt5SystemInfo) BuildRequires: pkgconfig(Qt5Qml) -BuildRequires: python +BuildRequires: python3-base BuildRequires: qt5-qttools-linguist %description @@ -34,11 +34,10 @@ libcontentaction library. %package tests Summary: Tests for libcontentaction Requires: %{name} = %{version}-%{release} -Requires: dbus-python -Requires: pygobject2 -Requires: python +Requires: dbus-python3 +Requires: python3-gobject +Requires: python3-base Requires: tracker-utils -Requires: qt5-default Requires: qt5-qttools-qdbus %description tests diff --git a/tests/applications/fixedparams.desktop b/tests/applications/fixedparams.desktop index 6c19ee0..d999391 100644 --- a/tests/applications/fixedparams.desktop +++ b/tests/applications/fixedparams.desktop @@ -5,7 +5,7 @@ GenericName=Launch Me Comment=Test helper X-Maemo-Service=just.a.gallery X-Maemo-Method=com.nokia.galleryserviceinterface.showImage -Exec=python -c "f = open('/tmp/actionParams', 'w'); f.write('The params are %U');" +Exec=python3 -c "f = open('/tmp/actionParams', 'w'); f.write('The params are %U');" X-Maemo-Fixed-Args=these;are;fixed Terminal=false MimeType=text/*; diff --git a/tests/applications/uberexec.desktop b/tests/applications/uberexec.desktop index 08491f0..7365102 100644 --- a/tests/applications/uberexec.desktop +++ b/tests/applications/uberexec.desktop @@ -6,7 +6,7 @@ Name[de]=deutschexec GenericName=Uber Program Icon=execicon Comment=View ANYTHING -Exec=python -c "f = open(%U); content=f.read(); f2 = open('/tmp/executedAction', 'w'); f2.write(content);" +Exec=python3 -c "f = open(%U); content=f.read(); f2 = open('/tmp/executedAction', 'w'); f2.write(content);" Terminal=false Type=Application MimeType=text/plain; diff --git a/tests/applications/uriprinter.desktop b/tests/applications/uriprinter.desktop index 6db2b22..57f6544 100644 --- a/tests/applications/uriprinter.desktop +++ b/tests/applications/uriprinter.desktop @@ -2,7 +2,7 @@ Encoding=UTF-8 Name=UriPrinter Comment=Just prints the params into a file -Exec=python -c "f2 = open('/tmp/executedAction', 'w'); f2.write(\\"%U\\n\\");" +Exec=python3 -c "f2 = open('/tmp/executedAction', 'w'); f2.write(\\"%U\\n\\");" Terminal=false Type=Application MimeType=image/png; diff --git a/tests/cltool.py b/tests/cltool.py index 12ec260..3065b86 100644 --- a/tests/cltool.py +++ b/tests/cltool.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2009 Nokia. All rights reserved. ## @@ -18,7 +18,7 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ## 02110-1301 USA -from __future__ import with_statement + import os import re @@ -99,7 +99,7 @@ def send(self, string): with self.iolock: self.io.append((time.time(), CLTool.STDIN, string)) try: - print >>self.process.stdin, string + print(string, file=self.process.stdin) self.process.stdin.flush() except: self.printio() @@ -115,7 +115,7 @@ def _last_output(self): """Compute the output read since the last match.""" r = [] with self.iolock: - for pos in xrange(self.last_expect, len(self.io)): + for pos in range(self.last_expect, len(self.io)): ts, fno, l = self.io[pos] if fno == CLTool.STDOUT: r.append(l) @@ -193,8 +193,8 @@ def wait(self): def printio(self): """Dump the io log to the standard output.""" - print - print '-' * 72 + print() + print('-' * 72) with self.iolock: for ts, fno, line in self.io: line = line.rstrip("\r\n") @@ -203,8 +203,8 @@ def printio(self): if fno == CLTool.COMMENT: info = "###"; if fno == CLTool.STDIN: info = "<--"; if fno == CLTool.STDOUT: info = "-->"; - print "%s %s %s" % (t, info, line) - print '-' * 72 + print("%s %s %s" % (t, info, line)) + print('-' * 72) sys.stdout.flush() def wanted(name, type, value): diff --git a/tests/gallery.py b/tests/gallery.py index fc17f2c..a3778d7 100755 --- a/tests/gallery.py +++ b/tests/gallery.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import dbus, dbus.service, dbus.mainloop.glib from gi.repository import GObject as gobject from sys import stdout, argv @@ -11,11 +11,11 @@ def __init__(self, path, busname): @dbus.service.method(dbus_interface='com.nokia.galleryserviceinterface', in_signature='as', out_signature='b') def showImage(self, uris): - print 'showImage ; %s' % (','.join(uris)) + print('showImage ; %s' % (','.join(uris))) stdout.flush() return True -print "started" +print("started") stdout.flush() dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) # if there is a command line parameter, use it as bus name (otherwise, use the diff --git a/tests/launchme.desktop b/tests/launchme.desktop index e7d6555..47e6675 100644 --- a/tests/launchme.desktop +++ b/tests/launchme.desktop @@ -3,7 +3,7 @@ Encoding=UTF-8 Name=launchme GenericName=Launch Me Comment=Test helper -Exec=python -c "f = open('/tmp/launchedAction', 'w'); f.write('I was launched');" +Exec=python3 -c "f = open('/tmp/launchedAction', 'w'); f.write('I was launched');" Terminal=false Type=Application diff --git a/tests/servicemapper.py b/tests/servicemapper.py index 9acd4c8..0b899bc 100755 --- a/tests/servicemapper.py +++ b/tests/servicemapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import dbus, dbus.service, dbus.mainloop.glib from gi.repository import GObject as gobject @@ -10,9 +10,9 @@ def __init__(self, path): dbus.SessionBus()) self.mapping = {} try: - execfile('service.map') + exec(compile(open('service.map', "rb").read(), 'service.map', 'exec')) except IOError: - execfile(os.path.dirname(__file__) + '/service.map') + exec(compile(open(os.path.dirname(__file__) + '/service.map', "rb").read(), os.path.dirname(__file__) + '/service.map', 'exec')) @dbus.service.method(dbus_interface='com.nokia.MServiceFwIf', in_signature='s', out_signature='s') @@ -37,12 +37,12 @@ def emitServiceUnavailable(self, implementor): @dbus.service.signal(dbus_interface='com.nokia.MServiceFwIf', signature='ss') def serviceAvailable(self, implementor, interface): - print "emit service available", implementor, interface + print("emit service available", implementor, interface) @dbus.service.signal(dbus_interface='com.nokia.MServiceFwIf', signature='s') def serviceUnavailable(self, implementor): - print "emit service unavailable", implementor + print("emit service unavailable", implementor) dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) napper = ServiceMapper('/') diff --git a/tests/test-defaults.py b/tests/test-defaults.py index 241795f..be70500 100755 --- a/tests/test-defaults.py +++ b/tests/test-defaults.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2008, 2009 Nokia. All rights reserved. ## @@ -27,7 +27,7 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool from tempfile import mkdtemp from shutil import rmtree @@ -42,35 +42,35 @@ def tearDown(self): def testSettingDefault(self): (status, output) = getstatusoutput("lca-tool --setmimedefault text/plain ubermeego") - self.assert_(status == 0) + self.assertTrue(status == 0) (status, output) = getstatusoutput("lca-tool --mimedefault text/plain") - self.assert_(status == 0) - self.assert_(output.find("ubermeego") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("ubermeego") != -1) def testDefaultIsFirst(self): (status, output) = getstatusoutput("lca-tool --setmimedefault text/plain uberexec") - self.assert_(status == 0) + self.assertTrue(status == 0) (status, output) = getstatusoutput("lca-tool --actionsformime text/plain") - self.assert_(status == 0) - self.assert_(output.find("uberexec") < output.find("ubermeego")) - self.assert_(output.find("uberexec") < output.find("ubermimeopen")) + self.assertTrue(status == 0) + self.assertTrue(output.find("uberexec") < output.find("ubermeego")) + self.assertTrue(output.find("uberexec") < output.find("ubermimeopen")) def testResettingDefault(self): # check what are the actions (in order) before (status, oldactions) = getstatusoutput("lca-tool --actionsformime text/plain") - self.assert_(status == 0) + self.assertTrue(status == 0) (status, output) = getstatusoutput("lca-tool --setmimedefault text/plain ubermeego") - self.assert_(status == 0) + self.assertTrue(status == 0) (status, output) = getstatusoutput("lca-tool --resetmimedefault text/plain") - self.assert_(status == 0) + self.assertTrue(status == 0) (status, newactions) = getstatusoutput("lca-tool --actionsformime text/plain") - self.assert_(status == 0) - self.assert_(newactions == oldactions) + self.assertTrue(status == 0) + self.assertTrue(newactions == oldactions) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(Defaults) diff --git a/tests/test-desktop-launching.py b/tests/test-desktop-launching.py index 6a2cf5d..b5bb0e7 100755 --- a/tests/test-desktop-launching.py +++ b/tests/test-desktop-launching.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2010 Nokia. All rights reserved. ## @@ -27,7 +27,7 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool import time @@ -40,20 +40,20 @@ class Launching(unittest.TestCase): def testActionsForDesktop(self): filename = "file://" + testfiles_dir + "/launchme.desktop" (status, output) = getstatusoutput("lca-tool --file --print " + filename) - self.assert_(status == 0) - self.assert_(output.find("launchme") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("launchme") != -1) def testLaunch(self): filename = "file://" + testfiles_dir + "/launchme.desktop" (status, output) = getstatusoutput("lca-tool --file --triggerdefault " + filename) - self.assert_(status == 0) + self.assertTrue(status == 0) time.sleep(3) f = open('/tmp/launchedAction') content = f.read() f.close() os.remove("/tmp/launchedAction") - self.assert_(content.find("I was launched") != -1) + self.assertTrue(content.find("I was launched") != -1) def testLaunchWithParams(self): (status, output) = getstatusoutput("lca-tool --triggerdesktop uriprinter.desktop param1 param2 param3") @@ -61,8 +61,8 @@ def testLaunchWithParams(self): content = f.read() f.close() os.remove("/tmp/executedAction") - self.assert_(status == 0) - self.assert_(content.find("'param1' 'param2' 'param3'") != -1) + self.assertTrue(status == 0) + self.assertTrue(content.find("'param1' 'param2' 'param3'") != -1) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(Launching) diff --git a/tests/test-fixed-params.py b/tests/test-fixed-params.py index 1f928ac..97b5711 100755 --- a/tests/test-fixed-params.py +++ b/tests/test-fixed-params.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2010 Nokia. All rights reserved. ## @@ -27,7 +27,7 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool # this controls where the test files are @@ -39,7 +39,7 @@ class FixedParams(unittest.TestCase): def setUp(self): # start a fake gallery service self.gallery = CLTool("gallery.py") - self.assert_(self.gallery.expect("started")) + self.assertTrue(self.gallery.expect("started")) def tearDown(self): self.gallery.kill() @@ -47,9 +47,9 @@ def tearDown(self): def testInvokeWithFixedParams(self): filename = "file://" + testfiles_dir + "/plaintext" (status, output) = getstatusoutput("lca-tool --file --trigger fixedparams " + filename) - self.assert_(status == 0) + self.assertTrue(status == 0) # assert that the gallery was invoked and the fixed params got prepended - self.assert_(self.gallery.expect("showImage ; these,are,fixed," + filename)) + self.assertTrue(self.gallery.expect("showImage ; these,are,fixed," + filename)) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(FixedParams) diff --git a/tests/test-invalid-defaults.py b/tests/test-invalid-defaults.py index d9c8737..339b62c 100755 --- a/tests/test-invalid-defaults.py +++ b/tests/test-invalid-defaults.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2008, 2009 Nokia. All rights reserved. ## @@ -27,7 +27,7 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool # this controls where the test files are @@ -40,14 +40,14 @@ def testInvalidDefaultForUri(self): # this uri is a ncal:Event, and x-maemo-nepomuk/calendar-event has a # mimeapps.list entry pointing to a nonexistent application. (status, output) = getstatusoutput("lca-tool --tracker --printdefault urn:test:calendarevent") - self.assert_(status == 0) - self.assert_(output.find("Invalid action") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("Invalid action") != -1) def testInvalidDefaultForFile(self): filename = "file://" + testfiles_dir + "/empty.pdf" (status, output) = getstatusoutput("lca-tool --file --printdefault " + filename) - self.assert_(status == 0) - self.assert_(output.find("Invalid action") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("Invalid action") != -1) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(InvalidDefaults) diff --git a/tests/test-invoking.py b/tests/test-invoking.py index 7ca5b50..01d8b5a 100755 --- a/tests/test-invoking.py +++ b/tests/test-invoking.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2008, 2009 Nokia. All rights reserved. ## @@ -27,57 +27,57 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool class Actions(unittest.TestCase): def setUp(self): # start a fake gallery service self.gallery = CLTool("gallery.py") - self.assert_(self.gallery.expect("started")) + self.assertTrue(self.gallery.expect("started")) def tearDown(self): self.gallery.kill() def testInvokeForImage(self): (status, output) = getstatusoutput("lca-tool --tracker --trigger gallerywithfilename an.image") - self.assert_(status == 0) + self.assertTrue(status == 0) # assert that the gallery was invoked - self.assert_(self.gallery.expect("showImage ; file:///tmp.aaa.jpg")) + self.assertTrue(self.gallery.expect("showImage ; file:///tmp.aaa.jpg")) def testInvokeForTwoImages(self): (status, output) = getstatusoutput("lca-tool --tracker --trigger gallerywithfilename an.image b.image") - self.assert_(status == 0) + self.assertTrue(status == 0) # assert that the gallery was invoked - self.assert_(self.gallery.expect("showImage ; file:///tmp/aaa.jpg,file:///tmp/bbb.png")) + self.assertTrue(self.gallery.expect("showImage ; file:///tmp/aaa.jpg,file:///tmp/bbb.png")) def testInvokeForInvalid(self): (status, output) = getstatusoutput("lca-tool --tracker --triggerdefault invalid.uri") - self.assert_(status >> 8 == 4) + self.assertTrue(status >> 8 == 4) def testInvokeForDifferentClasses(self): (status, output) = getstatusoutput("lca-tool --tracker --triggerdefault an.image a.contact") - self.assert_(status >> 8 == 4) + self.assertTrue(status >> 8 == 4) def testInvokeEnclosure(self): # We have " mfo:localLink ", and # triggering it should go indirectly via . (status, output) = getstatusoutput("lca-tool --tracker --trigger gallerywithfilename urn:test:encl1") - self.assert_(status == 0) - self.assert_(self.gallery.expect("showImage ; /tmp/aaa.jpg")) + self.assertTrue(status == 0) + self.assertTrue(self.gallery.expect("showImage ; /tmp/aaa.jpg")) def testEnclosureDefaults(self): # We have " mfo:localLink ", and # and should have the same # defaults. (status, encldef) = getstatusoutput("lca-tool --tracker --printdefault urn:test:encl1") - self.assert_(status == 0) + self.assertTrue(status == 0) (status, imgdef) = getstatusoutput("lca-tool --file --printdefault /tmp/aaa.jpg") - self.assert_(status == 0) + self.assertTrue(status == 0) # get the last line of the output encldef = encldef.split('\n')[-1] imgdef = imgdef.split('\n')[-1] - self.assert_(encldef != "" and encldef == imgdef) + self.assertTrue(encldef != "" and encldef == imgdef) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(Actions) diff --git a/tests/test-mimes.py b/tests/test-mimes.py index 3e17b9c..9efe068 100755 --- a/tests/test-mimes.py +++ b/tests/test-mimes.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2010 Nokia. All rights reserved. ## @@ -27,7 +27,7 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool # this controls where the test files are @@ -39,52 +39,52 @@ class Mimes(unittest.TestCase): def testActionsForPlain(self): filename = "file://" + testfiles_dir + "/plaintext" (status, output) = getstatusoutput("lca-tool --file --print " + filename) - self.assert_(status == 0) - self.assert_(output.find("uberexec") != -1) - self.assert_(output.find("ubermeego") != -1) - self.assert_(output.find("ubermimeopen") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("uberexec") != -1) + self.assertTrue(output.find("ubermeego") != -1) + self.assertTrue(output.find("ubermimeopen") != -1) def testInvokeMeego(self): program = CLTool("uberprogram.py") - self.assert_(program.expect("started")) + self.assertTrue(program.expect("started")) filename = "file://" + testfiles_dir + "/plaintext" (status, output) = getstatusoutput("lca-tool --file --trigger ubermeego " + filename) - self.assert_(status == 0) + self.assertTrue(status == 0) - self.assert_(program.expect("launch: ")) + self.assertTrue(program.expect("launch: ")) program.kill() def testInvokeMimeOpen(self): program = CLTool("uberprogram.py") - self.assert_(program.expect("started")) + self.assertTrue(program.expect("started")) filename = "file://" + testfiles_dir + "/plaintext" (status, output) = getstatusoutput("lca-tool --file --trigger ubermimeopen " + filename) - self.assert_(status == 0) + self.assertTrue(status == 0) - self.assert_(program.expect("mime_open:")) + self.assertTrue(program.expect("mime_open:")) program.kill() def testInvokeExec(self): filename = "file://" + testfiles_dir + "/plaintext" (status, output) = getstatusoutput("lca-tool --file --trigger uberexec " + filename) - self.assert_(status == 0) + self.assertTrue(status == 0) f = open("/tmp/executedAction") content = f.read() f.close() os.remove("/tmp/executedAction") - self.assert_(content.find("This is plain text") != -1) + self.assertTrue(content.find("This is plain text") != -1) def testInvokeExecMulti(self): filename = testfiles_dir + "/plaintext" (status, output) = getstatusoutput("lca-tool --file --trigger unterexec " + filename + " " + filename + "2") - self.assert_(status == 0) + self.assertTrue(status == 0) f = open("/tmp/executedParams") content = f.read() f.close() os.remove("/tmp/executedParams") - self.assert_(content == filename + "\n" + filename + "2\n"); + self.assertTrue(content == filename + "\n" + filename + "2\n"); def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(Mimes) diff --git a/tests/test-regexps.py b/tests/test-regexps.py index deda10c..4890881 100755 --- a/tests/test-regexps.py +++ b/tests/test-regexps.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2008-2010 Nokia. All rights reserved. ## @@ -27,7 +27,7 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool from tempfile import mkdtemp @@ -40,76 +40,76 @@ def tearDown(self): def testStringMimes1(self): # only the general (status, output) = getstatusoutput("lca-tool --string --printmimes foo") - self.assert_(status == 0) - self.assert_(output.find("general-1") != -1) - self.assert_(output.find("special-1a") == -1) - self.assert_(output.find("special-1b") == -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("general-1") != -1) + self.assertTrue(output.find("special-1a") == -1) + self.assertTrue(output.find("special-1b") == -1) # general and one special case (status, output) = getstatusoutput("lca-tool --string --printmimes foobar") - self.assert_(status == 0) - self.assert_(output.find("special-1a") != -1) - self.assert_(output.find("general-1") != -1) - self.assert_(output.find("special-1b") == -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("special-1a") != -1) + self.assertTrue(output.find("general-1") != -1) + self.assertTrue(output.find("special-1b") == -1) # verify the order - self.assert_(output.find("special-1a") < output.find("general-1")) + self.assertTrue(output.find("special-1a") < output.find("general-1")) # general and another special case (status, output) = getstatusoutput("lca-tool --string --printmimes foobazxx") - self.assert_(status == 0) - self.assert_(output.find("special-1b") != -1) - self.assert_(output.find("general-1") != -1) - self.assert_(output.find("special-1a") == -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("special-1b") != -1) + self.assertTrue(output.find("general-1") != -1) + self.assertTrue(output.find("special-1a") == -1) # verify the order - self.assert_(output.find("special-1b") < output.find("general-1")) + self.assertTrue(output.find("special-1b") < output.find("general-1")) def testStringMimes2(self): # only the general (status, output) = getstatusoutput("lca-tool --string --printmimes cat") - self.assert_(status == 0) - self.assert_(output.find("general-2") != -1) - self.assert_(output.find("special-2") == -1) - self.assert_(output.find("superspecial-2") == -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("general-2") != -1) + self.assertTrue(output.find("special-2") == -1) + self.assertTrue(output.find("superspecial-2") == -1) # general and one special case (status, output) = getstatusoutput("lca-tool --string --printmimes catdog") - self.assert_(status == 0) - self.assert_(output.find("general-2") != -1) - self.assert_(output.find("special-2") != -1) - self.assert_(output.find("superspecial-2") == -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("general-2") != -1) + self.assertTrue(output.find("special-2") != -1) + self.assertTrue(output.find("superspecial-2") == -1) # verify the order - self.assert_(output.find("special-2") < output.find("general-2")) + self.assertTrue(output.find("special-2") < output.find("general-2")) # general and both special cases (status, output) = getstatusoutput("lca-tool --string --printmimes catdogzebra") - self.assert_(status == 0) - self.assert_(output.find("general-2") != -1) - self.assert_(output.find("special-2") != -1) - self.assert_(output.find("superspecial-2") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("general-2") != -1) + self.assertTrue(output.find("special-2") != -1) + self.assertTrue(output.find("superspecial-2") != -1) # verify the order - self.assert_(output.find("special-2") < output.find("general-2")) - self.assert_(output.find("superspecial-2") < output.find("special-2")) + self.assertTrue(output.find("special-2") < output.find("general-2")) + self.assertTrue(output.find("superspecial-2") < output.find("special-2")) def testActionsForString(self): (status, output) = getstatusoutput("lca-tool --string --print www.foo.com") - self.assert_(status == 0) - self.assert_(output.find("browser") != -1) - self.assert_(output.find("special-browser") == -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("browser") != -1) + self.assertTrue(output.find("special-browser") == -1) (status, output) = getstatusoutput("lca-tool --string --print http://example.com") - self.assert_(status == 0) - self.assert_(output.find("special-browser") != -1) - self.assert_(output.find("browser") != -1) - self.assert_(output.find("special-browser") < output.find("browser")) + self.assertTrue(status == 0) + self.assertTrue(output.find("special-browser") != -1) + self.assertTrue(output.find("browser") != -1) + self.assertTrue(output.find("special-browser") < output.find("browser")) def testDefaultActionForString(self): (status, output) = getstatusoutput("lca-tool --string --printdefault www.foo.com") - self.assert_(status == 0) - self.assert_(output.find("browser") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("browser") != -1) (status, output) = getstatusoutput("lca-tool --string --printdefault http://example.com") - self.assert_(status == 0) - self.assert_(output.find("special-browser") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("special-browser") != -1) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(Regexps) diff --git a/tests/test-servicefw-signals.py b/tests/test-servicefw-signals.py index 3ba8525..40ff135 100755 --- a/tests/test-servicefw-signals.py +++ b/tests/test-servicefw-signals.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2008, 2009 Nokia. All rights reserved. ## @@ -34,14 +34,14 @@ class ServiceFWSignals(unittest.TestCase): def setUp(self): # start 2 fake gallery services self.gallery = CLTool("gallery.py", "just.a.gallery") - self.assert_(self.gallery.expect("started")) + self.assertTrue(self.gallery.expect("started")) self.gallery2 = CLTool("gallery.py", "just.another.gallery") - self.assert_(self.gallery2.expect("started")) + self.assertTrue(self.gallery2.expect("started")) # reset the mapping inside the service mapper p = Popen('qdbus com.nokia.MServiceFw / org.maemo.contentaction.testing.changeMapping "just.a.gallery" "com.nokia.galleryserviceinterface"', shell=True) sts = os.waitpid(p.pid, 0)[1] - self.assert_(sts == 0) + self.assertTrue(sts == 0) def tearDown(self): self.gallery.kill() @@ -51,45 +51,45 @@ def testImplementorChanges(self): invoker = CLTool("servicetest") # assert that the old implementor was invoked - self.assert_(self.gallery.expect("showImage ; an.image")) + self.assertTrue(self.gallery.expect("showImage ; an.image")) # change the mapping inside our mock service mapper p = Popen('qdbus com.nokia.MServiceFw / org.maemo.contentaction.testing.changeMapping "just.another.gallery" "com.nokia.galleryserviceinterface"', shell=True) sts = os.waitpid(p.pid, 0)[1] - self.assert_(sts == 0) + self.assertTrue(sts == 0) # then command our mock service mapper to send a signal that the # implementor has changed p = Popen('qdbus com.nokia.MServiceFw / org.maemo.contentaction.testing.emitServiceAvailable "just.another.gallery" "com.nokia.galleryserviceinterface"', shell=True) sts = os.waitpid(p.pid, 0)[1] - self.assert_(sts == 0) + self.assertTrue(sts == 0) # and the new implementor as well - self.assert_(self.gallery2.expect("showImage ; an.image", timeout=7)) + self.assertTrue(self.gallery2.expect("showImage ; an.image", timeout=7)) def testImplementorGone(self): invoker = CLTool("servicetest") # assert that the old implementor was invoked - self.assert_(self.gallery.expect("showImage ; an.image")) + self.assertTrue(self.gallery.expect("showImage ; an.image")) # change the mapping inside our mock service mapper p = Popen('qdbus com.nokia.MServiceFw / org.maemo.contentaction.testing.changeMapping "just.another.gallery" "com.nokia.galleryserviceinterface"', shell=True) sts = os.waitpid(p.pid, 0)[1] - self.assert_(sts == 0) + self.assertTrue(sts == 0) # then command our mock service mapper to send a signal that the # implementor is no longer available p = Popen('qdbus com.nokia.MServiceFw / org.maemo.contentaction.testing.emitServiceUnavailable "just.a.gallery"', shell=True) sts = os.waitpid(p.pid, 0)[1] - self.assert_(sts == 0) + self.assertTrue(sts == 0) # now, the implementor should be "just.another.gallery", because the # mapping was changed and the previous preferred implementor is no # longer available # and the new implementor as well - self.assert_(self.gallery2.expect("showImage ; an.image", timeout=7)) + self.assertTrue(self.gallery2.expect("showImage ; an.image", timeout=7)) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(ServiceFWSignals) diff --git a/tests/test-special-chars.py b/tests/test-special-chars.py index cdb0375..a97d0bc 100755 --- a/tests/test-special-chars.py +++ b/tests/test-special-chars.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ## ## Copyright (C) 2008, 2009 Nokia. All rights reserved. ## @@ -27,14 +27,14 @@ except: pass import unittest -from commands import getstatusoutput +from subprocess import getstatusoutput from cltool import CLTool class SpecialChars(unittest.TestCase): def setUp(self): # start a fake gallery service self.gallery = CLTool("gallery.py") - self.assert_(self.gallery.expect("started")) + self.assertTrue(self.gallery.expect("started")) (status, output) = getstatusoutput("touch /tmp/some#file.mp3") (status, output) = getstatusoutput("ls /tmp/some#file.mp3") @@ -44,30 +44,30 @@ def tearDown(self): def testDBusWithSpecialChars(self): (status, output) = getstatusoutput("lca-tool --tracker --trigger gallerywithfilename specialchars.image") - self.assert_(status == 0) + self.assertTrue(status == 0) # assert that the gallery was invoked - self.assert_(self.gallery.expect("showImage ; file:///tmp/%5Bspecial%5B.png")) + self.assertTrue(self.gallery.expect("showImage ; file:///tmp/%5Bspecial%5B.png")) def testExecWithSpecialChars(self): (status, output) = getstatusoutput("lca-tool --tracker --trigger uriprinter specialchars.image") - self.assert_(status == 0) + self.assertTrue(status == 0) f = open("/tmp/executedAction") content = f.read() f.close() os.remove("/tmp/executedAction") - self.assert_(content.find("'/tmp/[special[.png'") != -1) + self.assertTrue(content.find("'/tmp/[special[.png'") != -1) def testActionsForFileWithSpecialChars(self): filename = "file:///tmp/some%23file.mp3" (status, output) = getstatusoutput("lca-tool --file --print " + filename) - self.assert_(status == 0) - self.assert_(output.find("plainmusicplayer") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("plainmusicplayer") != -1) def testActionsForFileWithSpecialChars2(self): filename = "/tmp/some#file.mp3" (status, output) = getstatusoutput("lca-tool --file --print " + filename) - self.assert_(status == 0) - self.assert_(output.find("plainmusicplayer") != -1) + self.assertTrue(status == 0) + self.assertTrue(output.find("plainmusicplayer") != -1) def runTests(): suite = unittest.TestLoader().loadTestsFromTestCase(SpecialChars) diff --git a/tests/uberprogram.py b/tests/uberprogram.py index 06c6933..faf511f 100755 --- a/tests/uberprogram.py +++ b/tests/uberprogram.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import dbus, dbus.service, dbus.mainloop.glib from gi.repository import GObject as gobject from sys import stdout, argv @@ -11,15 +11,15 @@ def __init__(self, busname): @dbus.service.method(dbus_interface='com.nokia.MApplicationIf', in_signature='as') def launch(self, uris): - print 'launch:', uris + print('launch:', uris) stdout.flush() @dbus.service.method(dbus_interface="uber.program") def mime_open(self, *args): - print 'mime_open: ', args + print('mime_open: ', args) stdout.flush() -print "started" +print("started") stdout.flush() dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) # if there is a command line parameter, use it as bus name (otherwise, use the