FEM: unit test, add test to import Fem and FemGui

This commit is contained in:
Bernd Hahnebach
2019-09-11 08:12:00 +02:00
parent 5d2aba070d
commit 8a913cded8
3 changed files with 82 additions and 1 deletions

View File

@@ -132,6 +132,7 @@ SET(FemTests_SRCS
femtest/__init__.py
femtest/testccxtools.py
femtest/testcommon.py
femtest/testfemimport.py
femtest/testmaterial.py
femtest/testmesh.py
femtest/testobject.py

View File

@@ -26,6 +26,7 @@
# Unit test for the FEM module
# to get the right order import as is used
from femtest.testfemimport import TestFemImport as FemTest01
from femtest.testcommon import TestFemCommon as FemTest02
from femtest.testobject import TestObjectCreate as FemTest03
from femtest.testobject import TestObjectType as FemTest04
@@ -37,6 +38,7 @@ from femtest.testccxtools import TestCcxTools as FemTest09
from femtest.testsolverframework import TestSolverFrameWork as FemTest10
# dummy usage to get flake8 and lgtm quiet
False if FemTest01.__name__ else True
False if FemTest02.__name__ else True
False if FemTest03.__name__ else True
False if FemTest04.__name__ else True
@@ -86,7 +88,11 @@ unittest.TextTestRunner().run(alltest)
./bin/FreeCAD --run-test "TestFem"
./bin/FreeCADCmd --run-test "TestFem"
# module
# import Fem and FemGui
./bin/FreeCAD --run-test "femtest.testfemimport"
./bin/FreeCADCmd --run-test "femtest.testfemimport"
# other module
./bin/FreeCAD --run-test "femtest.testccxtools"
./bin/FreeCAD --run-test "femtest.testcommon"
./bin/FreeCAD --run-test "femtest.testmaterial"

View File

@@ -0,0 +1,74 @@
# ***************************************************************************
# * Copyright (c) 2019 - FreeCAD Developers *
# * Author: Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with FreeCAD; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
import unittest
import FreeCAD
from femtest.utilstest import fcc_print
class TestFemImport(unittest.TestCase):
fcc_print("import TestFemImport")
# ********************************************************************************************
# no is document needed to test import Fem and import FemGui
# thus neiter setUp nor tearDown methods are needed
def test_00print(
self
):
fcc_print("\n{0}\n{1} run FEM TestFemImport tests {2}\n{0}".format(
100 * "*",
10 * "*",
61 * "*"
))
# ********************************************************************************************
def test_import_fem(
self
):
mod = "Fem"
fcc_print("\n Try importing {0} ...".format(mod))
try:
im = __import__("{0}".format(mod))
except ImportError:
im = False
if not im:
# to get an error message what was going wrong
__import__("{0}".format(mod))
self.assertTrue(im, "Problem importing {0}".format(mod))
if FreeCAD.GuiUp:
mod = "FemGui"
fcc_print(" Try importing {0} ...".format(mod))
try:
im = __import__("{0}".format(mod))
except ImportError:
im = False
if not im:
# to get an error message what was going wrong
__import__("{0}".format(mod))
self.assertTrue(im, "Problem importing {0}".format(mod))