test_numpy_version.py 581 B

1234567891011121314151617
  1. import re
  2. import numpy as np
  3. from numpy.testing import assert_
  4. def test_valid_numpy_version():
  5. # Verify that the numpy version is a valid one (no .post suffix or other
  6. # nonsense). See gh-6431 for an issue caused by an invalid version.
  7. version_pattern = r"^[0-9]+\.[0-9]+\.[0-9]+(|a[0-9]|b[0-9]|rc[0-9])"
  8. dev_suffix = r"(\.dev0\+([0-9a-f]{7}|Unknown))"
  9. if np.version.release:
  10. res = re.match(version_pattern, np.__version__)
  11. else:
  12. res = re.match(version_pattern + dev_suffix, np.__version__)
  13. assert_(res is not None, np.__version__)