]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa/sdk/maturin: be less picky in the list_python test
authorRoss Burton <ross.burton@arm.com>
Sat, 10 May 2025 08:43:48 +0000 (09:43 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 12 May 2025 09:52:52 +0000 (10:52 +0100)
The test assumed that maturin would only find a single Python binary, in
/usr/bin/python3*.

However in eSDKs with buildtools a Python is shipped with the SDK, so
the test failed.

Generalise the test so that it runs python3 and obtains its path and
version, and then verifies that path and and version are found by
Maturin. This means we're not assuming a single Python, or the paths, or
that the Python is CPython.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/sdk/cases/maturin.py

index 42394c7a973296ebba60a235adceaf5db2974732..83d13c4ec59a5ecc8d30f02fffe9c24e78009c0f 100644 (file)
@@ -19,17 +19,15 @@ class MaturinTest(OESDKTestCase):
         self.ensure_host_package("python3-maturin")
 
     def test_maturin_list_python(self):
-        py_major = self._run("python3 -c 'import sys; print(sys.version_info.major)'")
-        py_minor = self._run("python3 -c 'import sys; print(sys.version_info.minor)'")
-        python_version = "%s.%s" % (py_major.strip(), py_minor.strip())
-        cmd = "maturin list-python"
-        output = self._run(cmd)
-        self.assertRegex(output, r"^🐍 1 python interpreter found:\n")
-        self.assertRegex(
-            output,
-            r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version),
-        )
+        out = self._run(r"""python3 -c 'import sys; print(f"{sys.executable}\n{sys.version_info.major}.{sys.version_info.minor}")'""")
+        executable, version = out.splitlines()
 
+        output = self._run("maturin list-python")
+        # The output looks like this:
+        # - CPython 3.13 at /usr/bin/python3
+        # We don't want to assume CPython so just check for the version and path.
+        expected = f"{version} at {executable}"
+        self.assertIn(expected, output)
 
 class MaturinDevelopTest(OESDKTestCase):
     @classmethod