Salome HOME
Copyright update 2022
[modules/homard.git] / src / tests / Test / tutorial_1.py
index 070277b551fcd88593ff7fafed0f8ccb6ac0a801..01647c572afc661f8700f597e565bfb0c8f1b0b5 100755 (executable)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
+# Copyright (C) 2011-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,7 +21,7 @@
 Python script for HOMARD
 Test tutorial_1 associe au tutorial 1
 """
-__revision__ = "V4.02"
+__revision__ = "V4.07"
 
 #========================================================================
 TEST_NAME = "tutorial_1"
@@ -29,40 +29,24 @@ DEBUG = False
 N_ITER_TEST_FILE = 3
 #========================================================================
 import os
-import tempfile
 import sys
-import HOMARD
-import salome
 #
 # ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+PATH_HOMARD = os.getenv("HOMARD_ROOT_DIR")
 # Repertoire des scripts utilitaires
 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(prefix=TEST_NAME)
-# Repertoire des donnees du tutorial
-DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
-DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
-sys.path.append(DATA_TUTORIAL)
-from tutorial_util import gzip_gunzip
 # ==================================
-gzip_gunzip(DATA_TUTORIAL, 1, -1)
+# RĂ©pertoires pour ce test
+REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
 # ==================================
-
+#
+import salome
 salome.salome_init()
+import HOMARD
 import iparameters
 IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
 IPAR.append("AP_MODULES_LIST", "Homard")
@@ -78,8 +62,8 @@ Python script for HOMARD
   message = ""
   #
   while not erreur :
-    #
-    HOMARD.SetCurrentStudy(salome.myStudy)
+  #
+  #  HOMARD.UpdateStudy()
     #
     # Hypotheses
     # ==========
@@ -149,12 +133,12 @@ while not ERREUR :
   assert HOMARD is not None, "Impossible to load homard engine"
   HOMARD.SetLanguageShort("fr")
 #
-  FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med")
+  FICMED = os.path.join(REP_DATA, TEST_NAME+".00.med")
   try:
     ERREUR, MESSAGE = homard_exec("MAILL", FICMED, DEBUG)
-  except Exception, eee:
+  except RuntimeError as eee:
     ERREUR = 2
-    MESSAGE = eee.message
+    MESSAGE = str(eee.message)
   #
   if ERREUR :
     MESSAGE += "Pb in homard_exec"
@@ -171,11 +155,8 @@ while not ERREUR :
 if ERREUR:
   raise Exception(MESSAGE)
 #
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 1, 1)
-# ==================================
 #
 if salome.sg.hasDesktop():
-  salome.sg.updateObjBrowser(True)
+  salome.sg.updateObjBrowser()
   iparameters.getSession().restoreVisualState(1)