Salome HOME
Merge branch 'V9_9_BR'
[modules/yacs.git] / src / yacsloader_swig / Test / testSave.py
index 1ecc00f2f00ecbdb5adfb1f0a87d14bc1cef2371..81d24ab7ab715f90efdf8e22e6cf8ea4db014261 100755 (executable)
@@ -1,5 +1,5 @@
-#!/usr/bin/env python
-# Copyright (C) 2006-2016  CEA/DEN, EDF R&D
+#!/usr/bin/env python3
+# 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
@@ -21,6 +21,8 @@
 import time
 import unittest
 import threading
+import tempfile
+import os
 
 import SALOMERuntime
 import loader
@@ -30,6 +32,7 @@ class TestSave(unittest.TestCase):
 
     def setUp(self):
         SALOMERuntime.RuntimeSALOME_setRuntime(1)
+        self.workdir = tempfile.mkdtemp(suffix=".yacstest")
         pass
 
     def test0_saveAndExec(self):
@@ -54,10 +57,10 @@ class TestSave(unittest.TestCase):
         e = pilot.ExecutorSwig()
         for schema in schemaList:
             fileOrig = "samples/" + schema + ".xml"
-            saveSchema1 = "schema1_" + schema
-            dumpSchema1 = "dump1_" + schema
-            saveSchema2 = "schema2_" + schema
-            dumpSchema2 = "dump2_" + schema
+            saveSchema1 = os.path.join(self.workdir, "schema1_" + schema)
+            dumpSchema1 = os.path.join(self.workdir, "dump1_" + schema)
+            saveSchema2 = os.path.join(self.workdir, "schema2_" + schema)
+            dumpSchema2 = os.path.join(self.workdir, "dump2_" + schema)
             try:
                 p = l.load(fileOrig)
                 s = pilot.SchemaSave(p)
@@ -96,9 +99,9 @@ class TestSave(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: testSave.py\n")
       suite = unittest.makeSuite(TestSave)
       result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)