1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2015 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Python script for HOMARD
22 Copyright EDF-R&D 2014
23 Utilitaires pour les tests
28 #========================================================================
29 #========================================================================
30 def remove_dir(directory) :
32 Empties, then removes a directory.
33 Copyright EDF-R&D 2013
36 l_aux = os.listdir(directory)
38 fic_a = os.path.join(directory, fic)
39 if os.path.isdir(fic_a) :
47 #========================================================================
48 #========================================================================
49 def test_results(rep_test, test_name, dircase, n_iter_test_file, n_rep_test_file, destroy_dir = True) :
52 rep_test: repertoire des tests
53 test_name: nom du test
54 dircase: repertoire des resultats du test
55 n_iter_test_file: numero de l'iteration a tester
56 n_rep_test_file: numero du repertoire de l'iteration a tester
57 destroy_dir: destruction du repertoire de calcul
58 Copyright EDF-R&D 2014
61 test_file_suff = "apad.%02d.bilan" % n_iter_test_file
62 rep_test_file = "I%02d" % n_rep_test_file
64 test_file = os.path.join(rep_test, test_name + "." + test_file_suff)
65 mess_error_ref = "\nReference file: " + test_file
67 file = open (test_file, "r")
68 mess_ref = file.readlines()
71 mess_error = mess_error_ref + "\nThis file does not exist.\n"
73 raise Exception(mess_error)
75 test_file = os.path.join(dircase, rep_test_file, test_file_suff)
76 if os.path.isfile (test_file) :
77 file = open (test_file, "r")
78 mess = file.readlines()
81 mess_error = "\nResult file: " + test_file
82 mess_error += "\nThis file does not exist.\n"
84 raise Exception(mess_error)
86 nblign = len(mess_ref)
87 if ( len(mess) != nblign ):
88 mess_error = mess_error_ref + "\nResult file: " + test_file
89 mess_error += "\nThe number of lines of the files are not the same.\n"
91 raise Exception(mess_error)
93 for num in range(nblign) :
94 if (( "creation" not in mess_ref[num] ) and ( mess_ref[num] != mess[num])) :
95 message_erreur = "\nRefe : " + mess_ref[num]
96 message_erreur += "Test : " + mess[num][:-1]
97 message_erreur += "\nThe test is different from the reference."
99 raise Exception(message_erreur)
106 #========================================================================
107 #========================================================================