Salome HOME
Updated copyright comment
[modules/homard.git] / src / tests / Test / test_1.py
index f9fe63ac54e0be8398569e22b870920381d5968d..d7dcb150a063901fe6339d1cdd53de0cdd3a1f02 100755 (executable)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
+# Copyright (C) 2011-2024  CEA, EDF
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -21,7 +21,7 @@
 Python script for HOMARD
 Test test_1
 """
-__revision__ = "V3.1"
+__revision__ = "V4.05"
 
 #========================================================================
 TEST_NAME = "test_1"
@@ -29,7 +29,6 @@ DEBUG = False
 N_ITER_TEST_FILE = 3
 #========================================================================
 import os
-import tempfile
 import sys
 import HOMARD
 import salome
@@ -40,22 +39,14 @@ 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()
+salome.salome_init_without_session()
 import iparameters
 IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
 IPAR.append("AP_MODULES_LIST", "Homard")
@@ -70,7 +61,7 @@ Python script for HOMARD
 #
   while not error :
   #
-    HOMARD.UpdateStudy()
+  #  HOMARD.UpdateStudy()
   #
   # Creation of the zones
   # =====================
@@ -108,10 +99,10 @@ Python script for HOMARD
     zones_1_et_2.AddZone('Zone_1_2', 1)
     laux = zones_1_et_2.GetZones()
     nbzone = len(laux) // 2
-    jaux = 0
+    iaux = 0
     for _ in range(nbzone) :
-      print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
-      jaux += 2
+      print(hyponame_2, " : ", dico[laux[iaux+1]], "sur la zone", laux[iaux])
+      iaux += 2
     print(hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName())
     if ( len (zones_1_et_2.GetFieldName()) > 0 ) :
       print(".. caractéristiques de l'adaptation :", zones_1_et_2.GetField())
@@ -184,6 +175,7 @@ Python script for HOMARD
     scriptfile = os.path.normpath(scriptfile)
     dirname = DIRCASE
     yacs_test_1 = case_test_1.CreateYACSSchema("YACS_test_1", scriptfile, dirname, mesh_file)
+    yacs_test_1.SetMaxIter(N_ITER_TEST_FILE)
     error = yacs_test_1.Write()
     if error :
       error = 4
@@ -205,8 +197,8 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception as eee:
-  raise Exception('Pb in homard_exec: ' + str(eee))
+except RuntimeError as eee:
+  raise Exception('Pb in homard_exec: '+str(eee.message))
 #
 # Test of the results
 #