1
# ***************************************************************************
2
# * Copyright (c) 2002 Juergen Riegel <juergen.riegel@web.de> *
4
# * This file is part of the FreeCAD CAx development system. *
6
# * This program is free software; you can redistribute it and/or modify *
7
# * it under the terms of the GNU Lesser General Public License (LGPL) *
8
# * as published by the Free Software Foundation; either version 2 of *
9
# * the License, or (at your option) any later version. *
10
# * for detail see the LICENCE text file. *
12
# * FreeCAD is distributed in the hope that it will be useful, *
13
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
# * GNU Library General Public License for more details. *
17
# * You should have received a copy of the GNU Library General Public *
18
# * License along with FreeCAD; if not, write to the Free Software *
19
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
22
# ***************************************************************************/
29
# ---------------------------------------------------------------------------
30
# define the functions to test the FreeCAD base code
31
# ---------------------------------------------------------------------------
34
def tryLoadingTest(testName):
35
"Loads and returns testName, or a failing TestCase if unsuccessful."
38
return unittest.defaultTestLoader.loadTestsFromName(testName)
42
class LoadFailed(unittest.TestCase):
43
def __init__(self, testName):
44
# setattr() first, because TestCase ctor checks for methodName.
45
setattr(self, "failed_to_load_" + testName, self._runTest)
46
super(LoadFailed, self).__init__("failed_to_load_" + testName)
47
self.testName = testName
50
return "Loading " + self.testName
53
self.fail("Couldn't load " + self.testName)
55
return LoadFailed(testName)
60
tests = FreeCAD.__unit_test__
62
suite = unittest.TestSuite()
65
suite.addTest(tryLoadingTest(test))
72
tests = FreeCAD.__unit_test__
74
suite = unittest.TestSuite()
76
FreeCAD.Console.PrintMessage("\nRegistered test units:\n\n")
78
FreeCAD.Console.PrintMessage(("%s\n" % test))
79
FreeCAD.Console.PrintMessage("\nPlease choose one or use 0 for all\n")
85
s = unittest.defaultTestLoader.loadTestsFromName(s)
86
r = unittest.TextTestRunner(stream=sys.stdout, verbosity=2)
88
# Flushing to make sure the stream is written to the console
89
# before the wrapping process stops executing. Without this line
90
# executing the tests from command line did not show stats
91
# and proper traceback in some cases.
101
r = unittest.TextTestRunner(stream=sys.stdout, verbosity=2)
106
TestText(unittest.TestLoader().loadTestsFromName("UnitTests"))
110
suite = unittest.TestSuite()
111
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("Document"))