diff options
author | Mark Asselstine <mark.asselstine@windriver.com> | 2023-04-05 13:57:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-05 19:57:32 +0200 |
commit | 55b7ca0163ac19178d615a067bc35fef177f3e84 (patch) | |
tree | 64d8cd69e5b770e8ba779fe353d7f188d1713995 | |
parent | 7eadee31db2f038763a3a6f978db1ea76bbc4674 (diff) | |
download | psutil-55b7ca0163ac19178d615a067bc35fef177f3e84.tar.gz |
Fix Linux test: allow '-dirty' or other version postfixes (#2221)
It is possible that 'free -V' will return a version that includes a
postfix such as '-dirty'. For example procps-ng will explicitly add
this when building from git:
https://gitlab.com/procps-ng/procps/-/blob/master/local/git-version-gen#L154
Process the version string to drop these string postfixes from the
version tuple, failing to do so will result in the test failing
File ".../psutil/tests/test_linux.py", line 204, in get_free_version_info
return tuple(map(int, out.split()[-1].split('.')))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '3-dirty'
Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
-rwxr-xr-x | psutil/tests/test_linux.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index e1de6706..ac11017a 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -201,7 +201,7 @@ def get_free_version_info(): out = sh(["free", "-V"]).strip() if 'UNKNOWN' in out: raise unittest.SkipTest("can't determine free version") - return tuple(map(int, out.split()[-1].split('.'))) + return tuple(map(int, re.findall(r'\d+', out.split()[-1]))) @contextlib.contextmanager |