From bbd340bc1a8caaec4fece1003ed2662e733fb15b Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 21 May 2018 14:32:19 +0200 Subject: [PATCH] FEM: unit tests, add some comment --- src/Mod/Fem/TestFem.py | 9 +++++++-- src/Mod/Fem/femtest/testcommon.py | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Mod/Fem/TestFem.py b/src/Mod/Fem/TestFem.py index 3b080b7e34..2665b46b6b 100644 --- a/src/Mod/Fem/TestFem.py +++ b/src/Mod/Fem/TestFem.py @@ -42,25 +42,30 @@ https://forum.freecadweb.org/viewtopic.php?f=10&t=22190#p175546 examples from within FreeCAD: +# module import Test, TestFem Test.runTestsFromModule(TestFem) import Test, femtest.testcommon Test.runTestsFromModule(femtest.testcommon) +# class import Test, TestFem Test.runTestsFromClass(TestFem.FemTest) import Test, femtest.testcommon Test.runTestsFromClass(femtest.testcommon.FemTest) - +# method import unittest mytest = unittest.TestLoader().loadTestsFromName("TestFem.FemTest.test_pyimport_all_FEM_modules") unittest.TextTestRunner().run(mytest) +import unittest +mytest = unittest.TestLoader().loadTestsFromName("TestFem.FemTest.test_femobjects_make") +unittest.TextTestRunner().run(mytest) - +# it may be useful to temporary comment FreeCAD.closeDocument("FemTest") in tearDown method to not close the document examples from shell in build dir: diff --git a/src/Mod/Fem/femtest/testcommon.py b/src/Mod/Fem/femtest/testcommon.py index f4117b9575..a64b1ba7c5 100644 --- a/src/Mod/Fem/femtest/testcommon.py +++ b/src/Mod/Fem/femtest/testcommon.py @@ -273,7 +273,9 @@ class FemTest(unittest.TestCase): analysis.addObject(ObjectsFem.makeEquationFlow(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFluxsolver(doc, sol)) analysis.addObject(ObjectsFem.makeEquationHeat(doc, sol)) - # TODO the equations show up twice on Tree (on solver and on analysis), if they are added to the analysis group + # TODO if the equations and gmsh mesh childs are added to the analysis, + # they show up twice on Tree (on solver resp. gemsh mesh obj and on analysis) + # https://forum.freecadweb.org/viewtopic.php?t=25283 doc.recompute() self.assertEqual(len(analysis.Group), testtools.get_defmake_count() - 1) # because of the analysis itself count -1