py3: Test: gathering diff of py3-branch

ec9dcf7453d44ce21e6ab5e460293006a49e7ccc
This commit is contained in:
looooo 2017-03-02 08:58:59 +01:00 committed by wmayer
parent dcdce7bab2
commit 99131438c6
3 changed files with 39 additions and 25 deletions

View File

@ -35,7 +35,11 @@ class ConsoleTestCase(unittest.TestCase):
FreeCAD.Console.PrintLog(" Printing Log\n")
def testSynchronPrintFromThread(self):
import thread, time
# http://python-kurs.eu/threads.php
try:
import _thread as thread, time
except:
import thread, time
def adder():
lock.acquire()
self.count=self.count+1
@ -52,7 +56,11 @@ class ConsoleTestCase(unittest.TestCase):
FreeCAD.Console.PrintMessage(str(self.count)+"\n")
def testAsynchronPrintFromThread(self):
import thread, time
# http://python-kurs.eu/threads.php
try:
import _thread as thread, time
except:
import thread, time
def adder():
self.count=self.count+1
# call of Console method is thread-safe
@ -191,14 +199,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(str(i),4711.4711)
self.TestPar.SetInt(str(i),4711)
self.TestPar.SetBool(str(i),1)
Temp = self.TestPar.GetGroup(str(i))
for l in range(50):
Temp.SetFloat(l,4711.4711)
Temp.SetInt(l,4711)
Temp.SetBool(l,1)
Temp.SetFloat(str(l),4711.4711)
Temp.SetInt(str(l),4711)
Temp.SetBool(str(l),1)
Temp = 0
def testExportImport(self):

View File

@ -58,7 +58,8 @@ class BaseGUITestRunner:
self.currentResult = None
self.running = 0
self.__rollbackImporter = None
apply(self.initGUI, args, kwargs)
#apply(self.initGUI, args, kwargs)
self.initGUI(args, kwargs)
def getSelectedTestName(self):
"Override to return the name of the test selected to be run"
@ -82,7 +83,8 @@ class BaseGUITestRunner:
test = unittest.defaultTestLoader.loadTestsFromName(testName)
except:
exc_type, exc_value, exc_tb = sys.exc_info()
apply(traceback.print_exception,sys.exc_info())
#apply(traceback.print_exception,sys.exc_info())
traceback.print_exception(*sys.exc_info())
self.errorDialog("Unable to run test '%s'" % testName,
"Error loading specified test: %s, %s" % \
(exc_type, exc_value))
@ -220,16 +222,20 @@ class QtTestRunner(BaseGUITestRunner):
def notifyTestFailed(self, test, err):
self.failCountVar=self.failCountVar+1
self.gui.setFailCount(self.failCountVar)
tracebackLines = apply(traceback.format_exception, err + (10,))
tracebackText = string.join(tracebackLines,'')
#tracebackLines = apply(traceback.format_exception, err + (10,))
tracebackLines = traceback.format_exception(*err + (10,))
#tracebackText = string.join(tracebackLines,'')
tracebackText = ''.join(tracebackLines)
self.gui.insertError("Failure: %s" % test,tracebackText)
self.errorInfo.append((test,err))
def notifyTestErrored(self, test, err):
self.errorCountVar=self.errorCountVar+1
self.gui.setErrorCount(self.errorCountVar)
tracebackLines = apply(traceback.format_exception, err + (10,))
tracebackText = string.join(tracebackLines,'')
#tracebackLines = apply(traceback.format_exception, err + (10,))
tracebackLines = traceback.format_exception(*err + (10,))
#tracebackText = string.join(tracebackLines,'')
tracebackText = ''.join(tracebackLines)
self.gui.insertError("Error: %s" % test,tracebackText)
self.errorInfo.append((test,err))

View File

@ -34,16 +34,16 @@ class WorkbenchTestCase(unittest.TestCase):
FreeCAD.Console.PrintLog(FreeCADGui.activeWorkbench().name())
def testActivate(self):
list=FreeCADGui.listWorkbenches()
wbs=FreeCADGui.listWorkbenches()
try:
for i in list:
for i in wbs:
FreeCADGui.activateWorkbench(i)
FreeCADGui.updateGui()
FreeCAD.Console.PrintLog("Active: "+FreeCADGui.activeWorkbench().name()+ " Expected: "+i+"\n")
FreeCADGui.updateGui()
self.failUnless(FreeCADGui.activeWorkbench().name()==i, "Test on activating workbench failed")
self.assertEqual(FreeCADGui.activeWorkbench().name(), i, "Test on activating workbench {0} failed".format(i))
except Exception as e:
self.failUnless(False, "Loading of workbench '%s' failed: %s" % (i, e.message))
self.fail("Loading of workbench '{0}' failed: {1}".format(i, e))
def testHandler(self):
import __main__
@ -51,20 +51,20 @@ class WorkbenchTestCase(unittest.TestCase):
MenuText = "Unittest"
ToolTip = "Unittest"
def Initialize(self):
list = ["Test_Test"]
self.appendToolbar("My Unittest",list)
cmds = ["Test_Test"]
self.appendToolbar("My Unittest",cmds)
def GetClassName(self):
return "Gui::PythonWorkbench"
FreeCADGui.addWorkbench(UnitWorkbench())
list=FreeCADGui.listWorkbenches()
self.failUnless(list.has_key("UnitWorkbench")==True, "Test on adding workbench handler failed")
wbs=FreeCADGui.listWorkbenches()
self.failUnless("UnitWorkbench" in wbs, "Test on adding workbench handler failed")
FreeCADGui.activateWorkbench("UnitWorkbench")
FreeCADGui.updateGui()
self.failUnless(FreeCADGui.activeWorkbench().name()=="UnitWorkbench", "Test on loading workbench 'Unittest' failed")
FreeCADGui.removeWorkbench("UnitWorkbench")
list=FreeCADGui.listWorkbenches()
self.failUnless(list.has_key("UnitWorkbench")==False, "Test on removing workbench handler failed")
wbs=FreeCADGui.listWorkbenches()
self.failUnless(not "UnitWorkbench" in wbs, "Test on removing workbench handler failed")
def tearDown(self):
FreeCADGui.activateWorkbench(self.Active.name())