Salome HOME
Use tempfile.mkdtemp to create temporary directory
[modules/yacs.git] / src / yacsloader_swig / Test / testLoader.py
index e1f4671d5adbec7339f3037429e85f0b294ecd35..1b3ad6fe498d156f517304e48580bee949249aae 100755 (executable)
@@ -1,4 +1,5 @@
-# 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
@@ -83,9 +84,11 @@ class TestLoader(unittest.TestCase):
     pass
 
 if __name__ == '__main__':
+  import tempfile
   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: testLoader.py\n")
       suite = unittest.makeSuite(TestLoader)
       result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)