]> SALOME platform Git repositories - modules/adao.git/blob - test/test1001/Versions.py
Salome HOME
Updating one salome test
[modules/adao.git] / test / test1001 / Versions.py
1 #!/usr/bin/env python
2 #-*-coding:iso-8859-1-*-
3 """Test des versions de modules"""
4
5 # Versions Calibre9/Jessie
6 minimal_python_version     = "2.7.9"
7 minimal_numpy_version      = "1.8.2"
8 minimal_scipy_version      = "0.14.0"
9 minimal_matplotlib_version = "1.4.2"
10
11 def compare_versions(v1,v2):
12     "Comparaison v1 >= v2"
13     for s in ['+', 'rc1', 'rc2', 'rc3']:
14         v1 = v1.replace(s,'',1)
15         v2 = v2.replace(s,'',1)
16     v11,v12,v13 = map(float,v1.split('.'))
17     v21,v22,v23 = map(float,v2.split('.'))
18     lv1 = 1e6*v11 + 1e3*v12 + v13
19     lv2 = 1e6*v21 + 1e3*v22 + v23
20     return lv1 >= lv2
21
22 def minimalVersion():
23     "Description"
24     print "  Les versions minimales attendues sont :"
25     print "    - Python systeme....: %s"%minimal_python_version
26     print "    - Numpy.............: %s"%minimal_numpy_version
27     print "    - Scipy.............: %s"%minimal_scipy_version
28     print "    - Matplotlib........: %s"%minimal_matplotlib_version
29     print
30
31 import sys
32 def testSysteme():
33     "Test des versions de modules"
34     print "  Les versions disponibles sont :"
35     v=sys.version.split()
36     print "    - Python systeme....: %s"%v[0]
37     assert compare_versions(sys.version.split()[0], minimal_python_version)
38     #
39     try:
40         import numpy
41         print "    - Numpy.............: %s"%numpy.version.version
42         assert compare_versions(numpy.version.version, minimal_numpy_version)
43     except ImportError:
44         return 1
45     #
46     try:
47         import scipy
48         print "    - Scipy.............: %s"%scipy.version.version
49         assert compare_versions(scipy.version.version, minimal_scipy_version)
50     except ImportError:
51         return 1
52     #
53     try:
54         import matplotlib
55         mplversion = matplotlib.__version__
56         print "    - Matplotlib........: %s"%mplversion
57         assert compare_versions(mplversion, minimal_matplotlib_version)
58         #
59         print
60         backends_OK = []
61         backends_KO = []
62         backend_now = matplotlib.get_backend()
63
64         for backend in ['bidon', 'pdf', 'pgf', 'Qt4Agg', 'GTK', 'GTKAgg', 'ps',
65                         'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg',
66                         'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg',
67                         'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX']:
68             try:
69                 matplotlib.use(backend)
70                 backends_OK.append(backend)
71             except ValueError:
72                 backends_KO.append(backend)
73         #
74         print "  Backends disponibles pour Matplotlib %s :"%mplversion
75         print "    Defaut initial......: '%s'"%backend_now
76         print "    Fonctionnant........:"
77         for b in backends_OK:
78             print "                          '%s'"%b
79         print "    Non fonctionnant....:"
80         for b in backends_KO:
81             print "                          '%s'"%b
82         print "    (Le backend 'bidon' n'est ici que pour verifier le test, il n'existe pas)"
83     except ImportError:
84         pass
85     print
86     #
87     return 0
88
89 #===============================================================================
90 if __name__ == "__main__":
91
92     print '\nAUTODIAGNOSTIC\n==============\n'
93
94     minimalVersion()
95     sys.exit(testSysteme())
96