10000 BUG: Fix test_numpy_version. by charris · Pull Request #19075 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix test_numpy_version. #19075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
charris committed May 23, 2021
commit 3c84e9ae0cc0082a31aa87252a48e3ae5f77bb93
25 changes: 21 additions & 4 deletions numpy/tests/test_numpy_version.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -7,11 +24,11 @@
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__)
2 changes: 1 addition & 1 deletion numpy/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
version: str = vinfo["version"]
full_version: str = vinfo['version']
git_revision: str = vinfo['full-revisionid']
release = 'dev0' not in version
release = 'dev0' not in version and '+' not in version

del get_versions, vinfo
0