diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2015-12-29 21:50:09 +0100 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@gmail.com> | 2016-01-16 12:18:27 +0100 |
commit | 08e75cad2b736cbed625ab3a831bb6f4887ca52e (patch) | |
tree | 288c728af7a7117874029fcfa99ebcedf7668d0b /numpy/tests | |
parent | 4aa9d578b85889530baec8a79a5570435eb0d5e1 (diff) | |
download | numpy-08e75cad2b736cbed625ab3a831bb6f4887ca52e.tar.gz |
TST: add test to check for correct version string format.
Implements idea suggested in gh-6431.
Diffstat (limited to 'numpy/tests')
-rw-r--r-- | numpy/tests/test_numpy_version.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/numpy/tests/test_numpy_version.py b/numpy/tests/test_numpy_version.py new file mode 100644 index 000000000..68d1508ce --- /dev/null +++ b/numpy/tests/test_numpy_version.py @@ -0,0 +1,23 @@ +from __future__ import division, absolute_import, print_function + +import re + +import numpy as np +from numpy.testing import assert_, run_module_suite + + +def test_valid_numpy_version(): + # Verify that the numpy version is a valid one (no .post suffix or other + # nonsense). See gh-6431 for an issue caused by an invalid version. + version_pattern = "^[0-9]+\.[0-9]+\.[0-9]+(|a[0-9]|b[0-9]|rc[0-9])" + dev_suffix = "+(\.dev0\+([0-9a-f]{7}|Unknown))" + if np.version.release: + res = re.match(version_pattern + "?$", np.__version__) + else: + res = re.match(version_pattern + dev_suffix + "?$", np.__version__) + + assert_(res is not None, np.__version__) + + +if __name__ == "__main__": + run_module_suite() |