|
11 | 11 |
|
12 | 12 | def _post_test_file_cleanup(): |
13 | 13 | """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) |
22 | 26 |
|
23 | 27 |
|
24 | 28 | @pytest.mark.slow |
@@ -148,16 +152,13 @@ def test_monte_carlo_plots_all_save(monte_carlo_calisto_pre_loaded): |
148 | 152 | keys="apogee", filename="test_histogram.png" |
149 | 153 | ) |
150 | 154 | assert os.path.exists("test_histogram_apogee.png") |
151 | | - os.remove("test_histogram_apogee.png") |
152 | 155 |
|
153 | 156 | # Test saving with multiple keys |
154 | 157 | monte_carlo_calisto_pre_loaded.plots.all( |
155 | 158 | keys=["apogee", "x_impact"], filename="test_multi.png" |
156 | 159 | ) |
157 | 160 | assert os.path.exists("test_multi_apogee.png") |
158 | 161 | assert os.path.exists("test_multi_x_impact.png") |
159 | | - os.remove("test_multi_apogee.png") |
160 | | - os.remove("test_multi_x_impact.png") |
161 | 162 | finally: |
162 | 163 | _post_test_file_cleanup() |
163 | 164 |
|
|
0 commit comments