Skip to content

Commit 1901cfe

Browse files
Improve test cleanup for monte_carlo_plots_all_save test
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
1 parent 02087e5 commit 1901cfe

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tests/integration/simulation/test_monte_carlo.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111

1212
def _post_test_file_cleanup():
1313
"""Clean monte carlo files after test session if they exist."""
14-
if os.path.exists("monte_carlo_class_example.kml"):
15-
os.remove("monte_carlo_class_example.kml")
16-
if os.path.exists("monte_carlo_test.errors.txt"):
17-
os.remove("monte_carlo_test.errors.txt")
18-
if os.path.exists("monte_carlo_test.inputs.txt"):
19-
os.remove("monte_carlo_test.inputs.txt")
20-
if os.path.exists("monte_carlo_test.outputs.txt"):
21-
os.remove("monte_carlo_test.outputs.txt")
14+
files_to_cleanup = [
15+
"monte_carlo_class_example.kml",
16+
"monte_carlo_test.errors.txt",
17+
"monte_carlo_test.inputs.txt",
18+
"monte_carlo_test.outputs.txt",
19+
"test_histogram_apogee.png",
20+
"test_multi_apogee.png",
21+
"test_multi_x_impact.png",
22+
]
23+
for filepath in files_to_cleanup:
24+
if os.path.exists(filepath):
25+
os.remove(filepath)
2226

2327

2428
@pytest.mark.slow
@@ -148,16 +152,13 @@ def test_monte_carlo_plots_all_save(monte_carlo_calisto_pre_loaded):
148152
keys="apogee", filename="test_histogram.png"
149153
)
150154
assert os.path.exists("test_histogram_apogee.png")
151-
os.remove("test_histogram_apogee.png")
152155

153156
# Test saving with multiple keys
154157
monte_carlo_calisto_pre_loaded.plots.all(
155158
keys=["apogee", "x_impact"], filename="test_multi.png"
156159
)
157160
assert os.path.exists("test_multi_apogee.png")
158161
assert os.path.exists("test_multi_x_impact.png")
159-
os.remove("test_multi_apogee.png")
160-
os.remove("test_multi_x_impact.png")
161162
finally:
162163
_post_test_file_cleanup()
163164

0 commit comments

Comments
 (0)