Skip to content

Commit 7c117e7

Browse files
committed
Fix race condition in TestRestart by individualizing project directory cleanup
1 parent b384e03 commit 7c117e7

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

functional/restart_test.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def test_restart_thermo(self):
128128
adj_list = ''.join(adj_lines)
129129
mol1 = Molecule().from_adjacency_list(adj_list)
130130
self.assertEqual(mol1.to_smiles(), 'OO')
131+
132+
shutil.rmtree(project_directory, ignore_errors=True)
131133

132134
def test_restart_rate_1(self):
133135
"""Test restarting ARC and attaining a reaction rate coefficient"""
@@ -151,6 +153,8 @@ def test_restart_rate_1(self):
151153
got_rate = True
152154
break
153155
self.assertTrue(got_rate)
156+
157+
shutil.rmtree(project_directory, ignore_errors=True)
154158

155159
def test_restart_rate_2(self):
156160
"""Test restarting ARC and attaining a reaction rate coefficient"""
@@ -178,6 +182,8 @@ def test_restart_rate_2(self):
178182
got_rate = True
179183
break
180184
self.assertTrue(got_rate)
185+
186+
shutil.rmtree(project_directory, ignore_errors=True)
181187

182188
def test_restart_bde (self):
183189
"""Test restarting ARC and attaining a BDE for anilino_radical."""
@@ -198,6 +204,8 @@ def test_restart_bde (self):
198204
self.assertIn(' BDE report for anilino_radical:\n', lines)
199205
self.assertIn(' (1, 9) N - H 353.92\n', lines)
200206

207+
shutil.rmtree(project_directory, ignore_errors=True)
208+
201209
def test_globalize_paths(self):
202210
"""Test modifying a YAML file's contents to correct absolute file paths"""
203211
project_directory = os.path.join(ARC_PATH, 'arc', 'testing', 'restart', '4_globalized_paths')
@@ -218,15 +226,6 @@ def tearDownClass(cls):
218226
A function that is run ONCE after all unit tests in this class.
219227
Delete all project directories created during these unit tests
220228
"""
221-
projects = ['arc_project_for_testing_delete_after_usage_restart_thermo',
222-
'arc_project_for_testing_delete_after_usage_restart_rate_1',
223-
'arc_project_for_testing_delete_after_usage_restart_rate_2',
224-
'test_restart_bde',
225-
]
226-
for project in projects:
227-
project_directory = os.path.join(ARC_PATH, 'Projects', project)
228-
shutil.rmtree(project_directory, ignore_errors=True)
229-
230229
shutil.rmtree(os.path.join(ARC_PATH, 'arc', 'testing', 'restart', '4_globalized_paths',
231230
'log_and_restart_archive'), ignore_errors=True)
232231
for file_name in ['arc.log', 'restart_paths_globalized.yml']:

0 commit comments

Comments
 (0)