1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2023 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
22 "Test du système et des versions de modules"
27 # ==============================================================================
29 # Versions minimales pour ADAO
30 # ----------------------------
31 minimal_python_version = "3.5.0"
32 minimal_numpy_version = "1.14.0"
33 minimal_scipy_version = "0.19.0"
34 minimal_matplotlib_version = "2.2.0"
35 minimal_nlopt_version = "2.4.2"
37 # ==============================================================================
38 class Test_Versions(unittest.TestCase):
39 def test1_minimalVersion(self):
40 "Affichage des versions minimales"
41 print(" Les versions minimales attendues sont :")
42 print(" - Python systeme....: %s"%minimal_python_version)
43 print(" - Numpy.............: %s"%minimal_numpy_version)
44 print(" - Scipy.............: %s"%minimal_scipy_version)
45 print(" - NLopt.............: %s"%minimal_nlopt_version)
46 print(" - Matplotlib........: %s"%minimal_matplotlib_version)
49 def test2_Version(self):
50 "Test du système et des versions de modules"
51 print(" Les versions disponibles sont :")
53 print(" - Python systeme....: %s"%v[0])
54 assert compare_versions(sys.version.split()[0], minimal_python_version)
56 def test3_Version(self):
59 print(" - Numpy.............: %s"%numpy.version.version)
60 assert compare_versions(numpy.version.version, minimal_numpy_version)
61 except ImportError as e:
62 raise ImportError(str(e))
64 def test4_Version(self):
67 print(" - Scipy.............: %s"%scipy.version.version)
68 assert compare_versions(scipy.version.version, minimal_scipy_version)
69 except ImportError as e:
70 raise ImportError(str(e))
72 def test5_Version(self):
75 __version = "%s.%s.%s"%(
76 nlopt.version_major(),
77 nlopt.version_minor(),
78 nlopt.version_bugfix(),
80 print(" - NLopt.............: %s"%__version)
81 assert compare_versions(__version, minimal_nlopt_version)
82 except ImportError as e:
83 raise ImportError(str(e))
85 def test6_Version(self):
88 mplversion = matplotlib.__version__
89 print(" - Matplotlib........: %s"%mplversion)
90 assert compare_versions(mplversion, minimal_matplotlib_version)
95 backend_now = matplotlib.get_backend()
98 'bidon', # Pour vérifier le test uniquement
116 matplotlib.use(backend)
117 backends_OK.append(backend)
119 backends_KO.append(backend)
123 print(" Backends disponibles pour Matplotlib %s :"%mplversion)
124 print(" Defaut initial......: '%s'"%backend_now)
125 print(" Fonctionnant........:")
126 for b in backends_OK:
128 print(" Non fonctionnant....:")
129 for b in backends_KO:
131 print(" (Le backend 'bidon' n'est ici que pour verifier le test, il n'existe pas)")
132 except ImportError as e:
133 raise ImportError(str(e))
135 print(" Les résultats obtenus sont corrects.")
138 def compare_versions(v1,v2):
139 "Comparaison v1 >= v2"
140 for s in ['+', 'rc1', 'rc2', 'rc3']:
141 v1 = v1.replace(s,'',1)
142 v2 = v2.replace(s,'',1)
143 v11,v12,v13 = list(map(float,v1.split('.')))
144 v21,v22,v23 = list(map(float,v2.split('.')))
145 lv1 = 1e6*v11 + 1e3*v12 + v13
146 lv2 = 1e6*v21 + 1e3*v22 + v23
149 #===============================================================================
150 if __name__ == "__main__":
151 print("\nAUTODIAGNOSTIC\n==============")
152 sys.stderr = sys.stdout
153 unittest.main(verbosity=2)