Skip to content

Commit

Permalink
fix [unittest] tear down function for dynamic test
Browse files Browse the repository at this point in the history
  • Loading branch information
sduess committed Sep 20, 2023
1 parent 8f4bb76 commit a0f43bf
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions tests/coupled/dynamic/test_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ def test_hale_dynamic(self):
import tests.coupled.dynamic.hale.generate_hale

case_name = 'hale'
route_test_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
cases_folder = os.path.join(route_test_dir, case_name)
self.route_file_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
cases_folder = os.path.join(self.route_file_dir, case_name)
output_folder = cases_folder + '/output/'

sharpy.sharpy_main.main(['', cases_folder + '/hale.sharpy'])
n_tstep = 5
# compare results with reference values
ref_Fz = -526.712530589119
ref_My =-1513.64676181859

file = os.path.join(output_folder, case_name, 'beam/beam_loads_%i.csv' % (n_tstep))
beam_loads_ts = np.loadtxt(file, delimiter=',')
np.testing.assert_almost_equal(float(beam_loads_ts[0, 6]), ref_Fz,
Expand All @@ -45,22 +46,21 @@ def test_hale_dynamic(self):
verbose=True)

@classmethod
def tearDownClass(cls):

def tearDown(self):
"""
Removes all created files within this test.
"""
import shutil
list_cases = ['hale']
list_file_extensions = ['.fem.h5', '.aero.h5', '.sharpy']
list_folders = ['output', '__pycache__']
for case in list_cases:
file_path = os.path.join(os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
case)
for folder in list_folders:
if os.path.isdir(folder):
shutil.rmtree(folder)
for extension in list_file_extensions:
os.remove(os.path.join(file_path, case + extension))
pass

folders = ['hale/output']
for folder in folders:
shutil.rmtree(self.route_file_dir + '/' + folder)
files = ['hale/hale.aero.h5', 'hale/hale.fem.h5', 'hale.hale.sharpy']
for file in files:
file_dir = self.route_file_dir + '/' + file
if os.path.isfile(file_dir):
os.remove(file_dir)



if __name__ == '__main__':
unittest.main()

0 comments on commit a0f43bf

Please sign in to comment.