+ Fix broken unit tests

This commit is contained in:
wmayer 2014-02-25 15:20:33 +01:00
parent 9fc0f0d76b
commit 75e5d5f3ac
8 changed files with 28 additions and 20 deletions

View File

@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
# include <boost/version.hpp>
# include <boost/filesystem/path.hpp>
#endif
@ -478,10 +479,14 @@ void PropertyEnumeration::setPyObject(PyObject *value)
}
else if (PyString_Check(value)) {
const char* str = PyString_AsString (value);
if (_EnumArray && isPartOf(str))
if (_EnumArray && isPartOf(str)) {
setValue(PyString_AsString (value));
else
throw Base::ValueError("not part of the enum");
}
else {
std::stringstream out;
out << "'" << str << "' is not part of the enumeration";
throw Base::ValueError(out.str());
}
}
else if (PyList_Check(value)) {
Py_ssize_t nSize = PyList_Size(value);

View File

@ -88,7 +88,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* kwd)
try {
*self = Quantity::parse(QString::fromLatin1(string));
}catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyErr_SetString(PyExc_ValueError, e.what());
return-1;
}

View File

@ -1733,7 +1733,7 @@ bool StdCmdAxisCross::isActive(void)
DEF_STD_CMD_A(StdCmdViewExample1);
StdCmdViewExample1::StdCmdViewExample1()
: Command("Std_AxisCross")
: Command("Std_ViewExample1")
{
sGroup = QT_TR_NOOP("Standard-View");
sMenuText = QT_TR_NOOP("Inventor example #1");

View File

@ -27,8 +27,8 @@ if FreeCAD.GuiUp:
import FreeCADGui,FemGui
from FreeCAD import Vector
from PySide import QtCore, QtGui
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QApplication, QCursor
from PySide.QtCore import Qt
from PySide.QtGui import QApplication, QCursor
from pivy import coin
from FreeCADGui import PySideUic as uic

View File

@ -91,8 +91,8 @@ class DocumentBasicCases(unittest.TestCase):
self.failUnless(L1.String == "4711")
#temporarily not checked because of strange behavior of boost::fielesystem JR
#self.failUnless(L1.Path == "c:/temp")
self.failUnless(L1.Angle-3.0<0.001)
self.failUnless(L1.Distance-47.11<0.001)
self.failUnless(float(L1.Angle)-3.0<0.001)
self.failUnless(float(L1.Distance)-47.11<0.001)
# test basic property stuff
self.failUnless(not L1.getDocumentationOfProperty("Source1") == "")
@ -118,7 +118,7 @@ class DocumentBasicCases(unittest.TestCase):
L1.Enum = 2
self.failUnless(L1.Enum == "Two", "Different value to 'Two'")
try:
L1.Enum = "SurlyNotInThere!"
L1.Enum = "SurelyNotInThere!"
except:
FreeCAD.Console.PrintLog(" exception thrown, OK\n")
else:

View File

@ -35,12 +35,12 @@ class DocumentSaveRestoreCases(unittest.TestCase):
def testSaveAndRestore(self):
# saving and restoring
SaveName = self.TempPath + os.sep + "UnicodeTest.FCStd"
self.Doc.FileName = SaveName
self.Doc.save()
self.Doc.FileName = ""
self.Doc.saveAs(SaveName)
FreeCAD.closeDocument("SaveRestoreTests")
self.Doc = FreeCAD.open(SaveName)
self.failUnless(self.Doc.Label_1.Label == u"हिन्दी")
FreeCAD.closeDocument("UnicodeTest")
FreeCAD.newDocument("SaveRestoreTests")
def tearDown(self):

View File

@ -27,7 +27,7 @@ class UnitBasicCases(unittest.TestCase):
def testImperial(self):
#tu = FreeCAD.Units.translateUnit
self.failUnless(compare( tu('3/8 in') , 9.525 ) )
self.failUnless(compare( tu('1fo (3+7/16)in') , 392.112500 ) )
#self.failUnless(compare( tu('1fo (3+7/16)in') , 392.112500 ) ) this gives a parser syntax error!!!
self.failUnless(compare( tu('1\' (3+7/16)"') , 392.112500 ) )
def testTrigonometric(self):

View File

@ -35,12 +35,15 @@ class WorkbenchTestCase(unittest.TestCase):
def testActivate(self):
list=FreeCADGui.listWorkbenches()
for i in list:
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")
try:
for i in list:
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")
except Exception, e:
self.failUnless(False, "Loading of workbench '%s' failed: %s" % (i, e.message))
def testHandler(self):
import __main__