Salome HOME
Merge V9_dev branch into master
[modules/homard.git] / src / tests / Test / test_5.py
index 439426c02ef8b994aa0f19c1aa8fd115cc1fc963..125a9626a95ef280df7272fe4e2cf79fb501f853 100755 (executable)
@@ -22,7 +22,7 @@ Python script for HOMARD
 Specific conditions for Code_Saturne
 Test test_5
 """
-__revision__ = "V2.01"
+__revision__ = "V2.03"
 
 #========================================================================
 TEST_NAME = "test_5"
@@ -38,7 +38,6 @@ LG_Z = 160.
 MESH_NAME = "MESH"
 #========================================================================
 import os
-import tempfile
 import sys
 import numpy as np
 import salome
@@ -52,19 +51,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
 REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
 REP_PYTHON = os.path.normpath(REP_PYTHON)
 sys.path.append(REP_PYTHON)
-from test_util import remove_dir
+from test_util import get_dir
 from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
-  DIRCASE = os.path.join("/tmp", TEST_NAME)
-  if ( os.path.isdir(DIRCASE) ) :
-    remove_dir(DIRCASE)
-  os.mkdir(DIRCASE)
-else :
-  DIRCASE = tempfile.mkdtemp()
+# ==================================
+# RĂ©pertoires pour ce test
+REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
 # ==================================
 
 salome.salome_init()
@@ -103,11 +94,11 @@ Python script for MED
 #
     coordinates = list()
     coo_z = -0.5*LG_Z
-    for kaux in range(nbno_z) :
+    for _ in range(nbno_z) :
       coo_y = -0.5*LG_Y
-      for jaux in range(nbno_y) :
+      for _ in range(nbno_y) :
         coo_x = -0.5*LG_X
-        for iaux in range(nbno_x) :
+        for _ in range(nbno_x) :
           coordinates.append(coo_x)
           coordinates.append(coo_y)
           coordinates.append(coo_z)
@@ -167,7 +158,7 @@ Python script for MED
       ficmed = os.path.join(DIRCASE, 'maill.00.med')
       #print "Ecriture du maillage dans le fichier", ficmed
       meshMEDFile3D.write(ficmed, 2)
-    except Exception as eee:
+    except IOError as eee:
       error = 2
       raise Exception('MEDFileUMesh.write() failed. ' + str(eee))
   #
@@ -308,7 +299,7 @@ try :
   ERROR = mesh_exec()
   if ERROR :
     raise Exception('Pb in mesh_exec')
-except Exception as eee:
+except RuntimeError as eee:
   raise Exception('Pb in mesh_exec: '+str(eee.message))
 
 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
@@ -321,7 +312,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception as eee:
+except RuntimeError as eee:
   raise Exception('Pb in homard_exec: '+str(eee.message))
 #
 # Test of the results