diff options
Diffstat (limited to 'lib/kross/test')
-rw-r--r-- | lib/kross/test/testcase.py | 88 | ||||
-rw-r--r-- | lib/kross/test/testgui.py | 42 | ||||
-rw-r--r-- | lib/kross/test/testkexidb.py | 52 | ||||
-rwxr-xr-x | lib/kross/test/testperformance.py | 4 |
4 files changed, 93 insertions, 93 deletions
diff --git a/lib/kross/test/testcase.py b/lib/kross/test/testcase.py index 28917f87..6db6d980 100644 --- a/lib/kross/test/testcase.py +++ b/lib/kross/test/testcase.py @@ -59,84 +59,84 @@ class TestPlugin(unittest.TestCase): def setUp(self): import krosstestpluginmodule self.pluginobject1 = krosstestpluginmodule.testpluginobject1() - self.assert_( self.pluginobject1 ) + self.assertTrue( self.pluginobject1 ) self.pluginobject2 = krosstestpluginmodule.testpluginobject2() - self.assert_( self.pluginobject2 ) + self.assertTrue( self.pluginobject2 ) self.testqobject1 = krosstestpluginmodule.testqobject1() - self.assert_( self.testqobject1 ) + self.assertTrue( self.testqobject1 ) def testBasicDataTypes(self): - self.assert_( self.pluginobject1.uintfunc(177321) == 177321 ) - self.assert_( self.pluginobject1.intfunc(93675) == 93675 ) - self.assert_( self.pluginobject1.intfunc(-73673) == -73673 ) - self.assert_( self.pluginobject1.boolfunc(True) == True ) - self.assert_( self.pluginobject1.boolfunc(False) == False ) - self.assert_( self.pluginobject1.doublefunc(4265.3723) == 4265.3723 ) - self.assert_( self.pluginobject1.doublefunc(-4265.68) == -4265.68 ) - self.assert_( self.pluginobject1.cstringfunc(" This is a Test! ") == " This is a Test! " ) - self.assert_( self.pluginobject1.stringfunc(" Another \n\r Test! $%&\"") == " Another \n\r Test! $%&\"" ) + self.assertTrue( self.pluginobject1.uintfunc(177321) == 177321 ) + self.assertTrue( self.pluginobject1.intfunc(93675) == 93675 ) + self.assertTrue( self.pluginobject1.intfunc(-73673) == -73673 ) + self.assertTrue( self.pluginobject1.boolfunc(True) == True ) + self.assertTrue( self.pluginobject1.boolfunc(False) == False ) + self.assertTrue( self.pluginobject1.doublefunc(4265.3723) == 4265.3723 ) + self.assertTrue( self.pluginobject1.doublefunc(-4265.68) == -4265.68 ) + self.assertTrue( self.pluginobject1.cstringfunc(" This is a Test! ") == " This is a Test! " ) + self.assertTrue( self.pluginobject1.stringfunc(" Another \n\r Test! $%&\"") == " Another \n\r Test! $%&\"" ) #TODO #self.assert_( self.pluginobject1.stringfunc( unicode(" Unicode test ") ) == " Unicode test " ) #self.assert_( self.pluginobject1.stringfunc(unicode(" Another Test! ")) == unicode(" Another Test! ") ) - self.assert_( self.pluginobject1.stringstringfunc("MyString1", "MyString2") == "MyString1" ) - self.assert_( self.pluginobject1.uintdoublestringfunc(8529,285.246,"String") == 8529 ) - self.assert_( self.pluginobject1.stringlistbooluintdouble(["s1","s2"],True,6,7.0,"String") == ["s1","s2"] ) + self.assertTrue( self.pluginobject1.stringstringfunc("MyString1", "MyString2") == "MyString1" ) + self.assertTrue( self.pluginobject1.uintdoublestringfunc(8529,285.246,"String") == 8529 ) + self.assertTrue( self.pluginobject1.stringlistbooluintdouble(["s1","s2"],True,6,7.0,"String") == ["s1","s2"] ) def testStringList(self): - self.assert_( self.pluginobject1.stringlistfunc( [] ) == [] ) - self.assert_( self.pluginobject1.stringlistfunc( ["First Item"," Second Item "] ) == ["First Item"," Second Item "] ) - self.assert_( self.pluginobject1.stringlistfunc( ("Theird Item"," Forth Item ","Fifth Item") ) == ["Theird Item"," Forth Item ","Fifth Item"] ) + self.assertTrue( self.pluginobject1.stringlistfunc( [] ) == [] ) + self.assertTrue( self.pluginobject1.stringlistfunc( ["First Item"," Second Item "] ) == ["First Item"," Second Item "] ) + self.assertTrue( self.pluginobject1.stringlistfunc( ("Theird Item"," Forth Item ","Fifth Item") ) == ["Theird Item"," Forth Item ","Fifth Item"] ) def testVariant(self): - self.assert_( self.pluginobject1.variantfunc(True) == True ) - self.assert_( self.pluginobject1.variantfunc(False) == False ) - self.assert_( self.pluginobject1.variantfunc(187937) == 187937 ) - self.assert_( self.pluginobject1.variantfunc(-69825) == -69825 ) - self.assert_( self.pluginobject1.variantfunc(8632.274) == 8632.274 ) - self.assert_( self.pluginobject1.variantfunc(-8632.351) == -8632.351 ) - self.assert_( self.pluginobject1.variantfunc(" Test \n\r This String $%&\"") == " Test \n\r This String $%&\"") + self.assertTrue( self.pluginobject1.variantfunc(True) == True ) + self.assertTrue( self.pluginobject1.variantfunc(False) == False ) + self.assertTrue( self.pluginobject1.variantfunc(187937) == 187937 ) + self.assertTrue( self.pluginobject1.variantfunc(-69825) == -69825 ) + self.assertTrue( self.pluginobject1.variantfunc(8632.274) == 8632.274 ) + self.assertTrue( self.pluginobject1.variantfunc(-8632.351) == -8632.351 ) + self.assertTrue( self.pluginobject1.variantfunc(" Test \n\r This String $%&\"") == " Test \n\r This String $%&\"") def testObjects(self): - print "-----------------1" + print("-----------------1") newobjref = self.pluginobject1.objectfunc(self.pluginobject2) - print "-----------------2" - print str(newobjref) + print("-----------------2") + print(str(newobjref)) #self.assert_( newobjref.myuniqueid == self.pluginobject2.myuniqueid ) #print "===========> %s" % self.pluginobject2.myName() - print "testqobject1 properties=%s" % self.testqobject1.propertyNames() - print "testqobject1 Q_SLOTS=%s" % self.testqobject1.slotNames() - print "testqobject1 Q_SIGNALS=%s" % self.testqobject1.signalNames() - print "-----------------3" - print "DIR=>%s" % dir(self.testqobject1) + print("testqobject1 properties=%s" % self.testqobject1.propertyNames()) + print("testqobject1 Q_SLOTS=%s" % self.testqobject1.slotNames()) + print("testqobject1 Q_SIGNALS=%s" % self.testqobject1.signalNames()) + print("-----------------3") + print("DIR=>%s" % dir(self.testqobject1)) - print "===================> slotcall-result: %s" % self.testqobject1.slot("self()") + print("===================> slotcall-result: %s" % self.testqobject1.slot("self()")) #testobject = newobjref.get("TestObject") #print testobject - print "-----------------9" + print("-----------------9") def testDefaultArguments(self): - self.assert_( self.pluginobject1.uintfunc_defarg(98765) == 98765 ) - self.assert_( self.pluginobject1.uintfunc_defarg() == 12345 ) - self.assert_( self.pluginobject1.stringfunc_defarg("MyString") == "MyString" ) - self.assert_( self.pluginobject1.stringfunc_defarg() == "MyDefaultString" ) - self.assert_( self.pluginobject1.stringlistfunc_defarg(["s1","s2","s3"]) == ["s1","s2","s3"] ) - self.assert_( self.pluginobject1.stringlistfunc_defarg() == ["Default1","Default2"] ) - self.assert_( self.pluginobject1.variantfunc_defarg(822.75173) == 822.75173 ) - self.assert_( self.pluginobject1.variantfunc_defarg() == "MyDefaultVariantString" ) + self.assertTrue( self.pluginobject1.uintfunc_defarg(98765) == 98765 ) + self.assertTrue( self.pluginobject1.uintfunc_defarg() == 12345 ) + self.assertTrue( self.pluginobject1.stringfunc_defarg("MyString") == "MyString" ) + self.assertTrue( self.pluginobject1.stringfunc_defarg() == "MyDefaultString" ) + self.assertTrue( self.pluginobject1.stringlistfunc_defarg(["s1","s2","s3"]) == ["s1","s2","s3"] ) + self.assertTrue( self.pluginobject1.stringlistfunc_defarg() == ["Default1","Default2"] ) + self.assertTrue( self.pluginobject1.variantfunc_defarg(822.75173) == 822.75173 ) + self.assertTrue( self.pluginobject1.variantfunc_defarg() == "MyDefaultVariantString" ) #def testExpectedFailures(self): # to less arguments #self.assertRaises(ValueError, self.pluginobject1.uintfunc) #self.assert_( self.pluginobject1.uintfunc() != 8465 ) -print "__name__ = %s" % __name__ +print("__name__ = %s" % __name__) #print "self = %s" % self #print self.get("TestObject") diff --git a/lib/kross/test/testgui.py b/lib/kross/test/testgui.py index b5efb8dc..0a3cf822 100644 --- a/lib/kross/test/testgui.py +++ b/lib/kross/test/testgui.py @@ -8,32 +8,32 @@ class TkTest: def __init__(self): - import Tkinter - self.root = Tkinter.Tk() + import tkinter + self.root = tkinter.Tk() self.root.title("TkTest") self.root.deiconify() - self.mainframe = Tkinter.Frame(self.root) + self.mainframe = tkinter.Frame(self.root) self.mainframe.pack() - self.button1 = Tkinter.Button(self.mainframe, text="Button1", command=self.callback1) - self.button1.pack(side=Tkinter.LEFT) + self.button1 = tkinter.Button(self.mainframe, text="Button1", command=self.callback1) + self.button1.pack(side=tkinter.LEFT) - self.button2 = Tkinter.Button(self.mainframe, text="Button2", command=self.callback2) - self.button2.pack(side=Tkinter.LEFT) + self.button2 = tkinter.Button(self.mainframe, text="Button2", command=self.callback2) + self.button2.pack(side=tkinter.LEFT) - self.exitbutton = Tkinter.Button(self.mainframe, text="Exit", command=self.root.destroy) - self.exitbutton.pack(side=Tkinter.LEFT) + self.exitbutton = tkinter.Button(self.mainframe, text="Exit", command=self.root.destroy) + self.exitbutton.pack(side=tkinter.LEFT) self.root.mainloop() def callback1(self): - import tkMessageBox - tkMessageBox.showinfo("Callback1", "Callback1 called.") + import tkinter.messagebox + tkinter.messagebox.showinfo("Callback1", "Callback1 called.") def callback2(self): - import tkMessageBox - tkMessageBox.showinfo("Callback2", "Callback2 called.") + import tkinter.messagebox + tkinter.messagebox.showinfo("Callback2", "Callback2 called.") class TQtTest: def __init__(self): @@ -41,7 +41,7 @@ class TQtTest: class Button(qt.TQPushButton): def __init__(self, *args): - apply(qt.TQPushButton.__init__, (self,) + args) + qt.TQPushButton.__init__(*(self,) + args) class ComboBox(qt.TQHBox): def __init__(self, parent, caption, items = []): @@ -56,7 +56,7 @@ class TQtTest: class FileChooser(qt.TQHBox): def __init__(self, *args): - apply(qt.TQHBox.__init__, (self,) + args) + qt.TQHBox.__init__(*(self,) + args) self.defaultfilename = "~/output.html" self.setSpacing(6) @@ -119,7 +119,7 @@ class TQtTest: qt.TQObject.connect(cancelbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("close()")) def accept(self): - print "ACCEPTTTTTTTT !!!!!!!!!!!!!!!!!!!!!!!!!!!!" + print("ACCEPTTTTTTTT !!!!!!!!!!!!!!!!!!!!!!!!!!!!") file = qt.TQFile( self.filechooser.file() ) #if not file.exists(): @@ -128,13 +128,13 @@ class TQtTest: # print "File '%s' does exist." % self.filechooser.file() def exportButtonClicked(self): - print "Export to HTML !!!!!!!!!!!!!!!!!!!!!!!!!!!!" + print("Export to HTML !!!!!!!!!!!!!!!!!!!!!!!!!!!!") def __getattr__(self, attr): - print "=> Dialog.__getattr__(self,attr)" + print("=> Dialog.__getattr__(self,attr)") #def closeEvent(self, ev): pass def event(self, e): - print "=> Dialog.event %s" % e + print("=> Dialog.event %s" % e) #self.deleteLater() #support.swapThreadState() # calls appropriate c-function return qt.TQDialog.event(self, e) @@ -143,7 +143,7 @@ class TQtTest: dialog = Dialog(app.mainWidget(), "Dialog", 1) dialog.show() -print "################## BEGIN" +print("################## BEGIN") #TkTest() TQtTest() -print "################## END" +print("################## END") diff --git a/lib/kross/test/testkexidb.py b/lib/kross/test/testkexidb.py index 803d6548..c85f9806 100644 --- a/lib/kross/test/testkexidb.py +++ b/lib/kross/test/testkexidb.py @@ -15,36 +15,36 @@ class KexiDBClass: #import KexiDB import krosskexidb self.kexidbmodule = krosskexidb - print "KrossKexiDB version=%s" % self.kexidbmodule.version() + print("KrossKexiDB version=%s" % self.kexidbmodule.version()) # Create and remember the drivermanager. self.drivermanager = self.kexidbmodule.DriverManager() # Print informations about the KexiDB module. def printKexiDB(self): - print "KexiDB = %s %s" % (str(self.kexidbmodule),dir(self.kexidbmodule)) + print("KexiDB = %s %s" % (str(self.kexidbmodule),dir(self.kexidbmodule))) # Each object has __name__ and __doc__ #print "KexiDB.__name__ = %s" % self.kexidbmodule.__name__ #print "KexiDB.__doc__ = %s" % self.kexidbmodule.__doc__ # Print some infos about the drivermanager. - print "drivermanager = %s %s" % (self.drivermanager,dir(self.drivermanager)) + print("drivermanager = %s %s" % (self.drivermanager,dir(self.drivermanager))) # The drivermanager holds a list of drivers he supports. - print "drivermanager.driverNames() = %s" % self.driverNames() + print("drivermanager.driverNames() = %s" % self.driverNames()) # Print informations about a driver. def printDriverManger(self, driver): - print "driver = %s %s" % (driver,dir(driver)) + print("driver = %s %s" % (driver,dir(driver))) # Each driver has a version to be able to determinate with what release we are working. - print "driver.versionMajor() = %s" % driver.versionMajor() - print "driver.versionMinor() = %s" % driver.versionMinor() + print("driver.versionMajor() = %s" % driver.versionMajor()) + print("driver.versionMinor() = %s" % driver.versionMinor()) # Show us what connections are opened right now. - print "driver.connectionsList() = %s" % str(driver.connectionsList()) + print("driver.connectionsList() = %s" % str(driver.connectionsList())) # Print informations about a connection. def printConnection(self, connection): - print "connection = %s %s" % (str(connection),dir(connection)) + print("connection = %s %s" % (str(connection),dir(connection))) # Print a list of all avaible databasenames this connection has. - print "connection.databaseNames() = %s" % connection.databaseNames() + print("connection.databaseNames() = %s" % connection.databaseNames()) # Return a list of drivernames. def driverNames(self): @@ -65,7 +65,7 @@ class KexiDBClass: # Fill the new connectiondata object with what we need to connect. connectiondata.setCaption("myFileConnection") connectiondata.setFileName(filename) - print "connectiondata.serverInfoString = %s" % connectiondata.serverInfoString() + print("connectiondata.serverInfoString = %s" % connectiondata.serverInfoString()) # Create the connection now. connection = driver.createConnection(connectiondata) # Establish the connection. @@ -98,23 +98,23 @@ class KexiDBClass: def testParser(self, connection, sqlstatement): parser = connection.parser() if not parser: - raise "ERROR in testParser(): Failed to create parser!" - print "parser.parse = %s" % parser.parse(sqlstatement) - print "parser.statement = %s" % parser.statement() - print "parser.operation = %s" % parser.operation() - print "parser.table = %s" % parser.table() - print "parser.query = %s" % parser.query() - print "parser.connection = %s" % parser.connection() + raise("ERROR in testParser(): Failed to create parser!") + print("parser.parse = %s" % parser.parse(sqlstatement)) + print("parser.statement = %s" % parser.statement()) + print("parser.operation = %s" % parser.operation()) + print("parser.table = %s" % parser.table()) + print("parser.query = %s" % parser.query()) + print("parser.connection = %s" % parser.connection()) # Execute the sql query statement and print the single string result. def printQuerySingleString(self, connection, sqlstatement): query = myfileconnection.querySingleString("SELECT * FROM table1", 0) - print "querySingleString = %s" % query + print("querySingleString = %s" % query) # Execute the sql query statement and print the single stringlist result. def printQueryStringList(self, connection, sqlstatement): query = myfileconnection.queryStringList("SELECT * FROM table1", 0) - print "queryStringList = %s" % query + print("queryStringList = %s" % query) # Walk through the KexiDBCursor and print all item values. def printQueryCursor(self, cursor): @@ -130,7 +130,7 @@ class KexiDBClass: while(not cursor.eof()): # Print for each item some infos about the fields and there content. for i in range( cursor.fieldCount() ): - print "Item='%s' Field='%s' Value='%s'" % (cursor.at(), i, cursor.value(i)) + print("Item='%s' Field='%s' Value='%s'" % (cursor.at(), i, cursor.value(i))) # Move to the next item cursor.moveNext() @@ -148,7 +148,7 @@ class KexiDBClass: field.setType("Text") field.setName(name) tableschema.fieldlist().addField(field) - print "tableschema.fieldlist().fieldCount() = %s" % tableschema.fieldlist().fieldCount() + print("tableschema.fieldlist().fieldCount() = %s" % tableschema.fieldlist().fieldCount()) return field # Create a table. @@ -156,7 +156,7 @@ class KexiDBClass: # First we need a new tableschema. tableschema = self.drivermanager.tableSchema(tablename) self.addField(tableschema, "myfield") - print "connection.createTable = %s" % connection.createTable(tableschema, True) + print("connection.createTable = %s" % connection.createTable(tableschema, True)) return tableschema # Drop a table. @@ -166,7 +166,7 @@ class KexiDBClass: # Alter the name of a table. def alterTableName(self, connection, tablename, newtablename): tableschema = connection.tableSchema(tablename) - print "alterTableName from=%s to=%s tableschema=%s" % (tablename, newtablename, tableschema) + print("alterTableName from=%s to=%s tableschema=%s" % (tablename, newtablename, tableschema)) connection.alterTableName(tableschema, newtablename) def testKexiDB(): @@ -209,6 +209,6 @@ def testKexiDB(): #del(mydriver) #del(mykexidbclass) -print "########## BEGIN TEST: KexiDB ##########" +print("########## BEGIN TEST: KexiDB ##########") testKexiDB() -print "########## END TEST: KexiDB ##########" +print("########## END TEST: KexiDB ##########") diff --git a/lib/kross/test/testperformance.py b/lib/kross/test/testperformance.py index a76453ed..bd9c6d2c 100755 --- a/lib/kross/test/testperformance.py +++ b/lib/kross/test/testperformance.py @@ -10,7 +10,7 @@ def runner(): testobject1 = krosstestpluginmodule.testpluginobject1() def testKexiDB(kexidbfile,drivername,sqlstring): - print "test kexidb" + print("test kexidb") import krosskexidb drivermanager = krosskexidb.DriverManager() connectiondata = drivermanager.createConnectionData() @@ -29,7 +29,7 @@ def runner(): cursor.moveNext() def test1(): - print "test1" + print("test1") for i in range(100000): testobject1.func1() testobject1.func1() |