Skip to content

Commit

Permalink
Use temp directory in montecarlo test
Browse files Browse the repository at this point in the history
  • Loading branch information
patkenneally committed Sep 24, 2024
1 parent 3c5548c commit 2b6fed4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utilities/MonteCarlo/_UnitTests/test_scenarioBasicOrbitMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#
import inspect # Don't worry about this, standard stuff plus file discovery
import os
import tempfile

filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
Expand Down Expand Up @@ -141,7 +142,10 @@ def myDataCallback(monteCarloData, retentionPolicy):
@pytest.mark.slowtest
def test_MonteCarloSimulation(show_plots):
# Test a montecarlo simulation
dirName = os.path.abspath(os.path.dirname(__file__)) + "/tmp_montecarlo_test"
tempDirectory = tempfile.TemporaryDirectory()
dirName = tempDirectory.name

# dirName = os.path.abspath(os.path.dirname(__file__)) + "/tmp_montecarlo_test"
monteCarlo = Controller()
monteCarlo.setShouldDisperseSeeds(True)
monteCarlo.setExecutionFunction(myExecutionFunction)
Expand Down Expand Up @@ -224,8 +228,8 @@ def test_MonteCarloSimulation(show_plots):
if show_plots:
plt.show()

shutil.rmtree(dirName)
assert not os.path.exists(dirName), "No leftover data should exist after the test"
# shutil.rmtree(dirName)
tempDirectory.cleanup()


if __name__ == "__main__":
Expand Down

0 comments on commit 2b6fed4

Please sign in to comment.