From c9810e32dbbb5f168f90a34a2c8f799202a84f02 Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Sun, 20 Aug 2023 17:03:37 +0100 Subject: [PATCH] tests: improve detected version testing --- test/test_pipe.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/test_pipe.py b/test/test_pipe.py index 3fa2435..47e3350 100644 --- a/test/test_pipe.py +++ b/test/test_pipe.py @@ -20,6 +20,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from itertools import takewhile from subprocess import check_output from test.utils import allpythons @@ -127,8 +128,14 @@ def test_python_version(py): meta = metadata(result.stdout) reported_version = ".".join((str(_) for _ in meta["python"])) - actual_version = ( - check_output([*python(py), "-V"]).decode().strip().partition(" ")[-1] + + # Take the version from the interpreter itself, discarding anything after + # the patchlevel. + actual_version = "".join( + takewhile( + lambda _: _.isdigit() or _ == ".", + (check_output([*python(py), "-V"]).decode().strip().partition(" ")[-1]), + ) ) assert reported_version == actual_version, meta