From 55b7ca0163ac19178d615a067bc35fef177f3e84 Mon Sep 17 00:00:00 2001 From: Mark Asselstine Date: Wed, 5 Apr 2023 13:57:32 -0400 Subject: 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 --- psutil/tests/test_linux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.1