Salome HOME
Use tempfile.mkdtemp to create temporary directory
[modules/yacs.git] / src / yacsloader_swig / Test / testResume.py
index a63c8a13d5b28e5d8332c852d253346695dca13c..d8dd3a6fa8cd6b8bbce9cc5cdaaa9f9753d1a010 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-# Copyright (C) 2006-2019  CEA/DEN, EDF R&D
+# Copyright (C) 2006-2022  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,7 @@ import os
 import SALOMERuntime
 import loader
 import pilot
+import salome
 
 class TestResume(unittest.TestCase):
 
@@ -39,6 +40,12 @@ class TestResume(unittest.TestCase):
         self.statefile = os.path.join(workdir, 'dumpPartialBloc2.xml')
         pass
 
+    def tearDown(self):
+      salome.salome_init()
+      cm = salome.lcc.getContainerManager()
+      cm.ShutdownContainers()
+      pass
+
     def test1_PartialExec(self):
         # --- stop execution after breakpoint
         time.sleep(1)
@@ -88,9 +95,9 @@ class TestResume(unittest.TestCase):
     pass
 
 if __name__ == '__main__':
-  import os
-  U = os.getenv('USER')
-  with open("/tmp/" + U + "/UnitTestsResult", 'a') as f:
+  dir_test = tempfile.mkdtemp(suffix=".yacstest")
+  file_test = os.path.join(dir_test,"UnitTestsResult")
+  with open(file_test, 'a') as f:
       f.write("  --- TEST src/yacsloader: testResume.py\n")
       suite = unittest.makeSuite(TestResume)
       result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)