diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-05-23 07:36:51 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2021-05-23 11:49:34 -0600 |
commit | d3d84017a230c1cc34517d19cb4fb9fc1854874d (patch) | |
tree | 7ecd286cbee994e29bdfeda2aee5090a770b6534 /numpy/tests | |
parent | b283e16320d962517381ec2202bb55d785b33e8c (diff) | |
download | numpy-d3d84017a230c1cc34517d19cb4fb9fc1854874d.tar.gz |
BUG: Fix test_numpy_version.
- Make versions of the form '1.22.0.dev0' valid for non-releases.
- Put empty match at end of groups instead of at the beginning.
- Require eol in match, do not allow trailing characters.
Diffstat (limited to 'numpy/tests')
-rw-r--r-- | numpy/tests/test_numpy_version.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/numpy/tests/test_numpy_version.py b/numpy/tests/test_numpy_version.py index 7fd566815..28595026e 100644 --- a/numpy/tests/test_numpy_version.py +++ b/numpy/tests/test_numpy_version.py @@ -1,3 +1,20 @@ +""" +Check the numpy version is valid. + +Note that a development version is marked by the presence of 'dev0' or '+' +in the version string, all else is treated as a release. The version string +itself is set from the output of ``git describe`` which relies on tags. + +Examples +-------- + +Valid Development: 1.22.0.dev0 1.22.0.dev0+5-g7999db4df2 1.22.0+5-g7999db4df2 +Valid Release: 1.21.0.rc1, 1.21.0.b1, 1.21.0 +Invalid: 1.22.0.dev, 1.22.0.dev0-5-g7999db4dfB, 1.21.0.d1, 1.21.a + +Note that a release is determined by the version string, which in turn +is controlled by the result of the ``git describe`` command. +""" import re import numpy as np @@ -7,11 +24,11 @@ from numpy.testing import assert_ 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 = r"^[0-9]+\.[0-9]+\.[0-9]+(|a[0-9]|b[0-9]|rc[0-9])" - dev_suffix = r"\.dev0\+[0-9]*\.g[0-9a-f]+" + version_pattern = r"^[0-9]+\.[0-9]+\.[0-9]+(a[0-9]|b[0-9]|rc[0-9]|)" + dev_suffix = r"(\.dev0|)(\+[0-9]*\.g[0-9a-f]+|)" if np.version.release: - res = re.match(version_pattern, np.__version__) + res = re.match(version_pattern + '$', np.__version__) else: - res = re.match(version_pattern + dev_suffix, np.__version__) + res = re.match(version_pattern + dev_suffix + '$', np.__version__) assert_(res is not None, np.__version__) |