14
from tables.req_versions import *
15
from tables.tests import common
16
from tables.utils import detectNumberOfCores
20
def get_tuple_version(hexversion):
21
"""Get a tuple from a compact version in hex."""
23
return(h & 0xff0000) >> 16, (h & 0xff00) >> 8, h & 0xff
29
'tables.tests.test_attributes',
30
'tables.tests.test_basics',
31
'tables.tests.test_create',
32
'tables.tests.test_backcompat',
33
'tables.tests.test_types',
34
'tables.tests.test_lists',
35
'tables.tests.test_tables',
36
'tables.tests.test_tablesMD',
37
'tables.tests.test_array',
38
'tables.tests.test_earray',
39
'tables.tests.test_carray',
40
'tables.tests.test_vlarray',
41
'tables.tests.test_tree',
42
'tables.tests.test_timetype',
43
'tables.tests.test_do_undo',
44
'tables.tests.test_enum',
45
'tables.tests.test_nestedtypes',
46
'tables.tests.test_hdf5compat',
47
'tables.tests.test_numpy',
48
'tables.tests.test_queries',
49
'tables.tests.test_expression',
50
'tables.tests.test_links',
51
'tables.tests.test_indexes',
52
'tables.tests.test_indexvalues',
53
'tables.tests.test_index_backcompat',
55
'tables.nodes.tests.test_filenode',
56
#'tables.netcdf3.tests.test_netcdf3',
59
# Numeric is now deprecated
60
# Add test_Numeric only if Numeric is installed
61
if False: # if common.numeric_imported:
63
print "Numeric (version %s) is present. Adding the Numeric test suite." % \
65
if Numeric.__version__ < min_numeric_version:
66
print "*Warning*: Numeric version is lower than recommended: %s < %s" % \
67
(Numeric.__version__, min_numeric_version)
68
test_modules.append("tables.tests.test_Numeric")
71
# Do not print this anymore
72
#print "Skipping Numeric test suite."
74
# numarray is now deprecated
75
# Add test_numarray only if numarray is installed
76
if False: # if common.numarray_imported:
79
"""numarray (version %s) is present. Adding the numarray test suite.""" % \
80
(numarray.__version__)
81
if numarray.__version__ < min_numarray_version:
83
"*Warning*: Numarray version is lower than recommended: %s < %s" % \
84
(numarray.__version__, min_numarray_version)
85
test_modules.append("tables.tests.test_numarray")
86
test_modules.append("tables.nra.tests.test_nestedrecords")
87
test_modules.append("tables.nra.tests.test_nriterators")
90
# Do not print this anymore
91
#print "Skipping numarray test suite."
95
# The test for garbage must be run *in the last place*.
96
# Else, it is not as useful.
97
test_modules.append('tables.tests.test_garbage')
99
alltests = unittest.TestSuite()
100
if common.show_memory:
101
# Add a memory report at the beginning
102
alltests.addTest(unittest.makeSuite(common.ShowMemTime))
103
for name in test_modules:
104
exec('from %s import suite as test_suite' % name)
105
alltests.addTest(test_suite())
106
if common.show_memory:
107
# Add a memory report after each test module
108
alltests.addTest(unittest.makeSuite(common.ShowMemTime))
112
def print_versions():
113
"""Print all the versions of software that PyTables relies on."""
115
print "PyTables version: %s" % tables.__version__
116
print "HDF5 version: %s" % tables.whichLibVersion("hdf5")[1]
117
print "NumPy version: %s" % numpy.__version__
118
tinfo = tables.whichLibVersion("zlib")
120
# Get only the main version number and strip out all the rest
121
vml_version = numexpr.get_vml_version()
122
vml_version = re.findall("[0-9.]+", vml_version)[0]
123
vml_avail = "using VML/MKL %s" % vml_version
125
vml_avail = "not using Intel's VML/MKL"
126
print "Numexpr version: %s (%s)" % (numexpr.__version__, vml_avail)
127
if tinfo is not None:
128
print "Zlib version: %s (%s)" % (tinfo[1], "in Python interpreter")
129
tinfo = tables.whichLibVersion("lzo")
130
if tinfo is not None:
131
print "LZO version: %s (%s)" % (tinfo[1], tinfo[2])
132
tinfo = tables.whichLibVersion("bzip2")
133
if tinfo is not None:
134
print "BZIP2 version: %s (%s)" % (tinfo[1], tinfo[2])
135
tinfo = tables.whichLibVersion("blosc")
136
blosc_date = tinfo[2].split()[1]
137
if tinfo is not None:
138
print "Blosc version: %s (%s)" % (tinfo[1], blosc_date)
140
from Cython.Compiler.Main import Version as Cython_Version
141
print 'Cython version: %s' % Cython_Version.version
144
print 'Python version: %s' % sys.version
145
if os.name == 'posix':
146
(sysname, nodename, release, version, machine) = os.uname()
147
print 'Platform: %s-%s' % (sys.platform, machine)
148
print 'Byte-ordering: %s' % sys.byteorder
149
print 'Detected cores: %s' % detectNumberOfCores()
153
def print_heavy(heavy):
156
Performing the complete test suite!"""
159
Performing only a light (yet comprehensive) subset of the test suite.
160
If you want a more complete test, try passing the --heavy flag to this script
161
(or set the 'heavy' parameter in case you are using tables.test() call).
162
The whole suite will take more than 4 hours to complete on a relatively
163
modern CPU and around 512 MB of main memory."""
167
def test(verbose=False, heavy=False):
169
Run all the tests in the test suite.
171
If `verbose` is set, the test suite will emit messages with full
172
verbosity (not recommended unless you are looking into a certain
175
If `heavy` is set, the test suite will be run in *heavy* mode (you
176
should be careful with this because it can take a lot of time and
177
resources from your computer).
182
# What a context this is!
183
oldverbose, common.verbose = common.verbose, verbose
184
oldheavy, common.heavy = common.heavy, heavy
186
unittest.TextTestRunner().run(suite())
188
common.verbose = oldverbose
189
common.heavy = oldheavy # there are pretty young heavies, too ;)
192
if __name__ == '__main__':
194
hdf5_version = get_tuple_version(tables.whichLibVersion("hdf5")[0])
195
if hdf5_version < min_hdf5_version:
196
print "*Warning*: HDF5 version is lower than recommended: %s < %s" % \
197
(hdf5_version, min_hdf5_version)
199
if numpy.__version__ < min_numpy_version:
200
print "*Warning*: NumPy version is lower than recommended: %s < %s" % \
201
(numpy.__version__, min_numpy_version)
203
# Handle some global flags (i.e. only useful for test_all.py)
207
# Remove 'show-versions' for PyTables 2.3 or higher
208
if arg in ['--print-versions', '--show-versions']:
211
elif arg == '--show-memory':
212
common.show_memory = True
216
if not only_versions:
217
print_heavy(common.heavy)
218
unittest.main(defaultTest='tables.tests.suite')