FEM: unit tests, code improvements
This commit is contained in:
@@ -45,8 +45,9 @@ class TestCcxTools(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# more inits
|
||||
self.mesh_name = "Mesh"
|
||||
@@ -56,9 +57,20 @@ class TestCcxTools(unittest.TestCase):
|
||||
"ccx"
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestCcxTools tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -487,13 +499,6 @@ class TestCcxTools(unittest.TestCase):
|
||||
|
||||
fcc_print("--------------- End of {} -------------------".format(test_name))
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# clearance, is executed after every test
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
def create_test_results():
|
||||
|
||||
@@ -43,12 +43,24 @@ class TestFemCommon(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestFemCommon tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -131,10 +143,3 @@ class TestFemCommon(unittest.TestCase):
|
||||
# to get an error message what was going wrong
|
||||
__import__("{0}".format(mod))
|
||||
self.assertTrue(im, "Problem importing {0}".format(mod))
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# clearance, is executed after every test
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
@@ -88,12 +88,23 @@ class TestObjectExistance(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
fcc_print("\n{0}\n{1} run FEM TestObjectExistance tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -190,9 +201,3 @@ class TestObjectExistance(unittest.TestCase):
|
||||
expected_obj_types,
|
||||
obj_types
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
@@ -41,12 +41,24 @@ class TestMaterialUnits(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestMaterialUnits tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -105,10 +117,3 @@ class TestMaterialUnits(unittest.TestCase):
|
||||
"Unit of quantity {} from material parameter {} is wrong."
|
||||
.format(value, param)
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# clearance, is executed after every test
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
@@ -43,12 +43,24 @@ class TestMeshCommon(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestMeshCommon tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -208,12 +220,6 @@ class TestMeshCommon(unittest.TestCase):
|
||||
)
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
# ************************************************************************************************
|
||||
@@ -225,8 +231,9 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# more inits
|
||||
self.elem = "tetra10"
|
||||
@@ -280,9 +287,20 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
fcc_print("\n")
|
||||
"""
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestMeshEleTetra10 tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -511,10 +529,3 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
femmesh_outfile,
|
||||
file_extension
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# clearance, is executed after every test
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
@@ -44,12 +44,24 @@ class TestObjectCreate(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestObjectCreate tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -99,12 +111,6 @@ class TestObjectCreate(unittest.TestCase):
|
||||
)
|
||||
self.document.saveAs(save_fc_file)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
# ************************************************************************************************
|
||||
@@ -116,12 +122,24 @@ class TestObjectType(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestObjectType tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -1467,13 +1485,6 @@ class TestObjectType(unittest.TestCase):
|
||||
# TODO: vtk post objs, thus 5 obj less than test_femobjects_make
|
||||
self.assertEqual(len(doc.Objects), testtools.get_defmake_count(False))
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# clearance, is executed after every test
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
|
||||
# helper
|
||||
def create_all_fem_objects_doc(
|
||||
|
||||
@@ -68,8 +68,9 @@ class TestObjectOpen(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
self.test_file_dir = join(
|
||||
testtools.get_fem_test_home_dir(),
|
||||
|
||||
@@ -42,12 +42,23 @@ class TestResult(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
fcc_print("\n{0}\n{1} run FEM TestResult tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -449,10 +460,3 @@ class TestResult(unittest.TestCase):
|
||||
expected_dispabs,
|
||||
"Calculated displacement abs are not the expected values."
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# clearance, is executed after every test
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
@@ -44,8 +44,9 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
self
|
||||
):
|
||||
# setUp is executed before every test
|
||||
self.doc_name = self.__class__.__name__
|
||||
self.document = FreeCAD.newDocument(self.doc_name)
|
||||
|
||||
# new document
|
||||
self.document = FreeCAD.newDocument(self.__class__.__name__)
|
||||
|
||||
# more inits
|
||||
self.mesh_name = "Mesh"
|
||||
@@ -54,9 +55,20 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
"FEM_solverframework"
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# tearDown is executed after every test
|
||||
FreeCAD.closeDocument(self.document.Name)
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_00print(
|
||||
self
|
||||
):
|
||||
# since method name starts with 00 this will be run first
|
||||
# this test just prints a line with stars
|
||||
|
||||
fcc_print("\n{0}\n{1} run FEM TestSolverFrameWork tests {2}\n{0}".format(
|
||||
100 * "*",
|
||||
10 * "*",
|
||||
@@ -185,10 +197,3 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
self.assertFalse(ret, "GMSH geo write file test failed.\n{}".format(ret))
|
||||
|
||||
fcc_print("--------------- End of FEM tests solver framework solver Elmer -----------")
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
):
|
||||
# clearance, is executed after every test
|
||||
FreeCAD.closeDocument(self.doc_name)
|
||||
|
||||
@@ -104,7 +104,6 @@ class TestObjectOpen(unittest.TestCase):
|
||||
fcc_print("load master head document objects")
|
||||
|
||||
# get a document with all FEM objects
|
||||
from femtest.app.test_object import create_all_fem_objects_doc
|
||||
self.document = create_all_fem_objects_doc(self.document)
|
||||
|
||||
# save and load the document
|
||||
|
||||
Reference in New Issue
Block a user