Skip to content
Permalink
Browse files

[sextante]improved classes for creating unit tests from GUI

  • Loading branch information
volaya committed Mar 23, 2013
1 parent 9465afa commit 176a08c7d1d5fcd7498b72d862f6794e1a086c87
Showing with 6 additions and 14 deletions.
  1. +1 −9 python/plugins/sextante/gui/HistoryDialog.py
  2. +5 −5 python/plugins/sextante/gui/TestTools.py
@@ -86,19 +86,11 @@ def changeText(self):
if isinstance(item, TreeLogEntryItem):
self.text.setText(item.entry.text.replace("|","\n"))



def createTest(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
TestTools.createTest(item)






TestTools.createTest(item.entry.text)

def showPopupMenu(self,point):
item = self.tree.currentItem()
@@ -32,9 +32,9 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.outputs.OutputVector import OutputVector

def createTest(item):
def createTest(text):
s = ""
tokens = item.entry.text[len("sextante.runalg("):-1].split(",")
tokens = text[len("sextante.runalg("):-1].split(",")
cmdname = tokens[0][1:-1];
methodname = "test_" + cmdname.replace(":","")
s += "def " + methodname + "():\n"
@@ -44,7 +44,7 @@ def createTest(item):
for token in tokens:
if i < alg.getVisibleParametersCount() + 1:
if os.path.exists(token[1:-1]):
token = '"' + os.path.basename(token[1:-1])[:-4] + '"'
token = os.path.basename(token[1:-1])[:-4]
execcommand+=token + ","
else:
execcommand+="None,"
@@ -69,8 +69,8 @@ def createTest(item):
fields = layer.pendingFields()
s+="\tlayer=sextante.getobject(output)\n"
s+="\tfields=layer.pendingFields()\n"
s+="\texpectednames=[" + ",".join([str(f.name()) for f in fields]) + "]\n"
s+="\texpectedtypes=[" + ",".join([str(f.typeName()) for f in fields]) + "]\n"
s+="\texpectednames=[" + ",".join(["'" + str(f.name()) + "'" for f in fields]) + "]\n"
s+="\texpectedtypes=[" + ",".join(["'" + str(f.typeName()) +"'" for f in fields]) + "]\n"
s+="\tnames=[str(f.name()) for f in fields]\n"
s+="\ttypes=[str(f.typeName()) for f in fields]\n"
s+="\tself.assertEqual(expectednames, names)\n"

0 comments on commit 176a08c

Please sign in to comment.
You can’t perform that action at this time.