22import os
33import unittest
44
5- from MLC .Population .Creation import BaseCreation
6- from tests .test_helpers import TestHelper
7- from MLC .config import get_working_directory
8- from MLC .config import get_test_path
9- from MLC .mlc_parameters .mlc_parameters import saved , Config
105from MLC .api .MLCLocal import MLCLocal
11-
12- from MLC .Simulation import Simulation
136from MLC .Application import Application , MLC_CALLBACKS
14-
7+ from MLC .config import set_working_directory
8+ from MLC .config import get_working_directory
9+ from MLC .config import get_test_path
1510from MLC .db .mlc_repository import MLCRepository
11+ from MLC .mlc_parameters .mlc_parameters import saved
12+ from MLC .mlc_parameters .mlc_parameters import Config
13+ from MLC .Population .Creation import BaseCreation
14+ from MLC .Simulation import Simulation
15+ from tests .test_helpers import TestHelper
1616
1717
1818class ApplicationTest (unittest .TestCase ):
@@ -22,20 +22,24 @@ class ApplicationTest(unittest.TestCase):
2222 on_new_generation = []
2323 on_finish = 0
2424 experiment_name = "test_application"
25- workspace_dir = os .path .join ( get_working_directory (), "workspace " )
25+ workspace_dir = os .path .abspath ( "/tmp/mlc_workspace/ " )
2626 test_conf_path = os .path .join (get_test_path (), TestHelper .DEFAULT_CONF_FILENAME )
2727 experiment_dir = os .path .join (workspace_dir , experiment_name )
2828 mlc_local = None
2929
3030 @classmethod
3131 def setUpClass (cls ):
3232 TestHelper .load_default_configuration ()
33- # Create the MLC workspace dir of this tests
34- os .makedirs (ApplicationTest .workspace_dir )
33+ try :
34+ os .makedirs (ApplicationTest .workspace_dir )
35+ except OSError :
36+ shutil .rmtree (ApplicationTest .workspace_dir )
37+ os .makedirs (ApplicationTest .workspace_dir )
3538
3639 # Create the MLCLocal and the workspace of MLC, and create
3740 # a new experiment to be used to test the callbacks
38- ApplicationTest .mlc_local = MLCLocal (ApplicationTest .workspace_dir )
41+ set_working_directory (ApplicationTest .workspace_dir )
42+ ApplicationTest .mlc_local = MLCLocal (working_dir = ApplicationTest .workspace_dir )
3943
4044 @classmethod
4145 def tearDownClass (cls ):
@@ -117,6 +121,7 @@ def test_set_custom_gen_creator(self):
117121 from MLC .individual .Individual import Individual
118122
119123 class TestCreator (BaseCreation ):
124+
120125 def __init__ (self ):
121126 BaseCreation .__init__ (self )
122127
@@ -137,4 +142,3 @@ def individuals(self):
137142 # Assert first Population was filled using the TestCreator
138143 population = MLCRepository .get_instance ().get_population (1 )
139144 self .assertEqual (population .get_individuals (), [1 , 2 , 3 , 4 , 5 ])
140-
0 commit comments