python: Test: *.py: Fix python3 syntax

This commit is contained in:
Priit Laes 2016-03-12 15:22:37 +02:00 committed by wmayer
parent 946c126866
commit 91e2e0043b
8 changed files with 54 additions and 57 deletions

View File

@ -191,14 +191,14 @@ class ParameterTestCase(unittest.TestCase):
# Parameter testing
#FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n")
for i in range(50):
self.TestPar.SetFloat(`i`,4711.4711)
self.TestPar.SetInt(`i`,4711)
self.TestPar.SetBool(`i`,1)
Temp = self.TestPar.GetGroup(`i`)
self.TestPar.SetFloat(i,4711.4711)
self.TestPar.SetInt(i,4711)
self.TestPar.SetBool(i,1)
Temp = self.TestPar.GetGroup(i)
for l in range(50):
Temp.SetFloat(`l`,4711.4711)
Temp.SetInt(`l`,4711)
Temp.SetBool(`l`,1)
Temp.SetFloat(l,4711.4711)
Temp.SetInt(l,4711)
Temp.SetBool(l,1)
Temp = 0
def testExportImport(self):

View File

@ -133,16 +133,16 @@ class GUITestResult(unittest.TestResult):
Used by BaseGUITestRunner. Need not be created directly.
"""
def __init__(self, callback):
unittest.TestResult.__init__(self)
self.callback = callback
unittest.TestResult.__init__(self)
self.callback = callback
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
self.callback.notifyTestErrored(test, err)
unittest.TestResult.addError(self, test, err)
self.callback.notifyTestErrored(test, err)
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
self.callback.notifyTestFailed(test, err)
unittest.TestResult.addFailure(self, test, err)
self.callback.notifyTestFailed(test, err)
def stopTest(self, test):
unittest.TestResult.stopTest(self, test)

View File

@ -144,7 +144,7 @@ class TestWorkbenchCmd:
FreeCADGui.updateGui()
FreeCADGui.activateWorkbench("PartWorkbench")
FreeCADGui.updateGui()
print i
print(i)
i=i+1
FreeCADGui.activateWorkbench("TestWorkbench")

View File

@ -42,7 +42,7 @@ class WorkbenchTestCase(unittest.TestCase):
FreeCAD.Console.PrintLog("Active: "+FreeCADGui.activeWorkbench().name()+ " Expected: "+i+"\n")
FreeCADGui.updateGui()
self.failUnless(FreeCADGui.activeWorkbench().name()==i, "Test on activating workbench failed")
except Exception, e:
except Exception as e:
self.failUnless(False, "Loading of workbench '%s' failed: %s" % (i, e.message))
def testHandler(self):

View File

@ -10,7 +10,7 @@ import FreeCAD
import Part
import Draft
print "testPathArray started"
print("testPathArray started")
items = 4 # count
centretrans = FreeCAD.Vector(0,0,0) # no translation
#centretrans = FreeCAD.Vector(-5,-5,0) # translation
@ -18,9 +18,9 @@ orient = True # align to curve
#orient = False # don't align to curve
s = FreeCADGui.Selection.getSelection()
print "testPathArray: Objects in selection: ", len(s)
print "First object in selection is a: ", s[0].Shape.ShapeType
print "Second object in selection is a: ", s[1].Shape.ShapeType
print("testPathArray: Objects in selection: ", len(s))
print("First object in selection is a: ", s[0].Shape.ShapeType)
print("Second object in selection is a: ", s[1].Shape.ShapeType)
base = s[0]
path = s[1]
pathsubs = []
@ -28,7 +28,7 @@ pathsubs = []
#o = Draft.makePathArray(base,path,items) # test with defaults
o = Draft.makePathArray(base,path,items,centretrans,orient,pathsubs) # test with non-defaults
print "testPathArray ended"
print("testPathArray ended")

View File

@ -9,7 +9,7 @@ import FreeCAD
import Part
import Draft
print "testPathArray started"
print("testPathArray started")
items = 4 # count
centretrans = FreeCAD.Vector(0,0,0) # translation
#centretrans = FreeCAD.Vector(10,10,10) # translation
@ -19,22 +19,19 @@ orient = True # align to curve
# use this to test w/ path subelements
s = FreeCADGui.Selection.getSelectionEx()
for o in s:
print "Selection: ", o.ObjectName
print("Selection: ", o.ObjectName)
for name in o.SubElementNames:
print " name: ", name
print(" name: ", name)
for obj in o.SubObjects:
print " object: ",obj
print(" object: ",obj)
print "testPathArray: Objects in selection: ", len(s)
print("testPathArray: Objects in selection: ", len(s))
base = s[0].Object
path = s[1].Object
pathsubs = list(s[1].SubElementNames)
print "testPathArray: pathsubs: ", pathsubs
print("testPathArray: pathsubs: ", pathsubs)
#o = Draft.makePathArray(base,path,items) # test with defaults
o = Draft.makePathArray(base,path,items,centretrans,orient,pathsubs) # test w/o orienting shapes
print "testPathArray ended"
print("testPathArray ended")

View File

@ -7,7 +7,7 @@ import FreeCAD
import Part
import PartDesign
print "testWire started"
print("testWire started")
# test strings
# if string contains funky characters, it has to be declared as Unicode or it
@ -38,15 +38,15 @@ FontName = 'Arial.ttf'
Height = 2000 # out string height FCunits
Track = 0 # intercharacter spacing
print "testWire.py input String contains ", len(String), " characters."
print("testWire.py input String contains ", len(String), " characters.")
s = Part.makeWireString(String,FontPath,FontName,Height,Track)
print "returned from makeWireString"
print "testWire.py output contains ", len(s), " WireChars."
print("returned from makeWireString")
print("testWire.py output contains ", len(s), " WireChars.")
for char in s:
for contour in char:
Part.show(contour)
print "testWire ended."
print("testWire ended.")

View File

@ -126,16 +126,16 @@ class GUITestResult(unittest.TestResult):
Used by BaseGUITestRunner. Need not be created directly.
"""
def __init__(self, callback):
unittest.TestResult.__init__(self)
self.callback = callback
unittest.TestResult.__init__(self)
self.callback = callback
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
self.callback.notifyTestErrored(test, err)
unittest.TestResult.addError(self, test, err)
self.callback.notifyTestErrored(test, err)
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
self.callback.notifyTestFailed(test, err)
unittest.TestResult.addFailure(self, test, err)
self.callback.notifyTestFailed(test, err)
def stopTest(self, test):
unittest.TestResult.stopTest(self, test)
@ -194,16 +194,16 @@ class TkTestRunner(BaseGUITestRunner):
"""
self.root = root
# Set up values that will be tied to widgets
self.suiteNameVar = tk.StringVar()
self.suiteNameVar.set(initialTestName)
self.suiteNameVar = tk.StringVar()
self.suiteNameVar.set(initialTestName)
self.statusVar = tk.StringVar()
self.statusVar.set("Idle")
self.runCountVar = tk.IntVar()
self.failCountVar = tk.IntVar()
self.errorCountVar = tk.IntVar()
self.remainingCountVar = tk.IntVar()
self.runCountVar = tk.IntVar()
self.failCountVar = tk.IntVar()
self.errorCountVar = tk.IntVar()
self.remainingCountVar = tk.IntVar()
self.top = tk.Frame()
self.top.pack(fill=tk.BOTH, expand=1)
self.top.pack(fill=tk.BOTH, expand=1)
self.createWidgets()
def createWidgets(self):
@ -217,11 +217,11 @@ class TkTestRunner(BaseGUITestRunner):
statusFrame.pack(anchor=tk.SW, fill=tk.X, side=tk.BOTTOM)
tk.Label(statusFrame, textvariable=self.statusVar).pack(side=tk.LEFT)
# Area to enter name of test to run
# Area to enter name of test to run
leftFrame = tk.Frame(self.top, borderwidth=3)
leftFrame.pack(fill=tk.BOTH, side=tk.LEFT, anchor=tk.NW, expand=1)
suiteNameFrame = tk.Frame(leftFrame, borderwidth=3)
suiteNameFrame.pack(fill=tk.X)
suiteNameFrame = tk.Frame(leftFrame, borderwidth=3)
suiteNameFrame.pack(fill=tk.X)
tk.Label(suiteNameFrame, text="Enter test name:").pack(side=tk.LEFT)
e = tk.Entry(suiteNameFrame, textvariable=self.suiteNameVar, width=25)
e.pack(side=tk.LEFT, fill=tk.X, expand=1)
@ -236,12 +236,12 @@ class TkTestRunner(BaseGUITestRunner):
borderwidth=2)
self.progressBar.pack(fill=tk.X, expand=1)
# Area with buttons to start/stop tests and quit
# Area with buttons to start/stop tests and quit
buttonFrame = tk.Frame(self.top, borderwidth=3)
buttonFrame.pack(side=tk.LEFT, anchor=tk.NW, fill=tk.Y)
self.stopGoButton = tk.Button(buttonFrame, text="Start",
self.stopGoButton = tk.Button(buttonFrame, text="Start",
command=self.runClicked)
self.stopGoButton.pack(fill=tk.X)
self.stopGoButton.pack(fill=tk.X)
tk.Button(buttonFrame, text="Close",
command=self.top.quit).pack(side=tk.BOTTOM, fill=tk.X)
tk.Button(buttonFrame, text="About",
@ -249,7 +249,7 @@ class TkTestRunner(BaseGUITestRunner):
tk.Button(buttonFrame, text="Help",
command=self.showHelpDialog).pack(side=tk.BOTTOM, fill=tk.X)
# Area with labels reporting results
# Area with labels reporting results
for label, var in (('Run:', self.runCountVar),
('Failures:', self.failCountVar),
('Errors:', self.errorCountVar),
@ -263,10 +263,10 @@ class TkTestRunner(BaseGUITestRunner):
tk.Label(leftFrame, text="Failures and errors:").pack(anchor=tk.W)
listFrame = tk.Frame(leftFrame, relief=tk.SUNKEN, borderwidth=2)
listFrame.pack(fill=tk.BOTH, anchor=tk.NW, expand=1)
self.errorListbox = tk.Listbox(listFrame, foreground='red',
self.errorListbox = tk.Listbox(listFrame, foreground='red',
selectmode=tk.SINGLE,
selectborderwidth=0)
self.errorListbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=1,
self.errorListbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=1,
anchor=tk.NW)
listScroll = tk.Scrollbar(listFrame, command=self.errorListbox.yview)
listScroll.pack(side=tk.LEFT, fill=tk.Y, anchor=tk.N)