diff --git a/src/Mod/Fem/femtest/app/test_ccxtools.py b/src/Mod/Fem/femtest/app/test_ccxtools.py index 5b75aa6ae9..5f7892def0 100644 --- a/src/Mod/Fem/femtest/app/test_ccxtools.py +++ b/src/Mod/Fem/femtest/app/test_ccxtools.py @@ -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(): diff --git a/src/Mod/Fem/femtest/app/test_common.py b/src/Mod/Fem/femtest/app/test_common.py index 163cc8ad79..aa17d70463 100644 --- a/src/Mod/Fem/femtest/app/test_common.py +++ b/src/Mod/Fem/femtest/app/test_common.py @@ -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) diff --git a/src/Mod/Fem/femtest/app/test_femimport.py b/src/Mod/Fem/femtest/app/test_femimport.py index e33db2cd23..7acafb4e8e 100644 --- a/src/Mod/Fem/femtest/app/test_femimport.py +++ b/src/Mod/Fem/femtest/app/test_femimport.py @@ -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) diff --git a/src/Mod/Fem/femtest/app/test_material.py b/src/Mod/Fem/femtest/app/test_material.py index f45b33513d..08a895ab23 100644 --- a/src/Mod/Fem/femtest/app/test_material.py +++ b/src/Mod/Fem/femtest/app/test_material.py @@ -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) diff --git a/src/Mod/Fem/femtest/app/test_mesh.py b/src/Mod/Fem/femtest/app/test_mesh.py index 4750b433da..453da6a7f9 100644 --- a/src/Mod/Fem/femtest/app/test_mesh.py +++ b/src/Mod/Fem/femtest/app/test_mesh.py @@ -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) diff --git a/src/Mod/Fem/femtest/app/test_object.py b/src/Mod/Fem/femtest/app/test_object.py index 34b637cc46..d139ae49bf 100644 --- a/src/Mod/Fem/femtest/app/test_object.py +++ b/src/Mod/Fem/femtest/app/test_object.py @@ -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( diff --git a/src/Mod/Fem/femtest/app/test_open.py b/src/Mod/Fem/femtest/app/test_open.py index a003725f5d..4fc696d817 100644 --- a/src/Mod/Fem/femtest/app/test_open.py +++ b/src/Mod/Fem/femtest/app/test_open.py @@ -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(), diff --git a/src/Mod/Fem/femtest/app/test_result.py b/src/Mod/Fem/femtest/app/test_result.py index 618a541b7e..2ec987a918 100644 --- a/src/Mod/Fem/femtest/app/test_result.py +++ b/src/Mod/Fem/femtest/app/test_result.py @@ -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) diff --git a/src/Mod/Fem/femtest/app/test_solverframework.py b/src/Mod/Fem/femtest/app/test_solverframework.py index e7fcbdf2b9..88b933941b 100644 --- a/src/Mod/Fem/femtest/app/test_solverframework.py +++ b/src/Mod/Fem/femtest/app/test_solverframework.py @@ -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) diff --git a/src/Mod/Fem/femtest/gui/test_open.py b/src/Mod/Fem/femtest/gui/test_open.py index 4c7816d772..440d1c9884 100644 --- a/src/Mod/Fem/femtest/gui/test_open.py +++ b/src/Mod/Fem/femtest/gui/test_open.py @@ -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