diff mbox series

[meta-python,10/16] python3-typer: fix ptest rich text-wrapping and subprocess PYTHONPATH

Message ID 20260829001108.559544-10-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-python,01/16] python3-bleak: fetch git tag with tests/ for ptest instead of PyPI sdist | expand

Commit Message

Khem Raj Aug. 29, 2026, 12:11 a.m. UTC
From: Khem Raj <raj.khem@gmail.com>

Force a wide console (COLUMNS=200) so rich does not wrap/truncate the
error-panel text. Several tests assert on trailing substrings ("is a
file", "is a directory", "unknown error") of long error messages
that get word-wrapped - and thus split - inside an 80-column rich
panel when stdout is not a tty (as in the ptest QEMU environment). A
wide terminal keeps the message on one line.

test_binary_stderr spawns a fresh interpreter to run the test file as
a script; the file does "from tests.utils import ...", so the ptest
root (the parent of tests/) must be importable in that subprocess -
export it via PYTHONPATH.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 .../recipes-devtools/python/python3-typer/run-ptest  | 12 ++++++++++++
 .../recipes-devtools/python/python3-typer_0.27.1.bb  |  2 ++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-typer/run-ptest b/meta-python/recipes-devtools/python/python3-typer/run-ptest
index 526825aadf..c1472b4914 100644
--- a/meta-python/recipes-devtools/python/python3-typer/run-ptest
+++ b/meta-python/recipes-devtools/python/python3-typer/run-ptest
@@ -1,5 +1,17 @@ 
 #!/bin/sh
 
+# Force a wide console so rich does not wrap/truncate the error-panel text.
+# Several tests assert on trailing substrings ("is a file", "is a directory",
+# "unknown error") of long error messages that get word-wrapped - and thus
+# split - inside an 80-column rich panel when stdout is not a tty (as in the
+# ptest QEMU environment). A wide terminal keeps the message on one line.
+export COLUMNS=200
+
+# test_binary_stderr spawns a fresh interpreter to run this test file as a
+# script; the file does "from tests.utils import ...", so the ptest root (the
+# parent of tests/) must be importable in that subprocess.
+export PYTHONPATH="$(pwd)${PYTHONPATH:+:$PYTHONPATH}"
+
 # Ignore the test_tutorial and test_completion.
 # Because it needs the docs_src package what is not in Yocto.
 # And the tests are not that useful for Yocto.
diff --git a/meta-python/recipes-devtools/python/python3-typer_0.27.1.bb b/meta-python/recipes-devtools/python/python3-typer_0.27.1.bb
index 12c7bc7f61..3246de7472 100644
--- a/meta-python/recipes-devtools/python/python3-typer_0.27.1.bb
+++ b/meta-python/recipes-devtools/python/python3-typer_0.27.1.bb
@@ -46,4 +46,6 @@  RDEPENDS:${PN}-ptest += "\
 do_install_ptest() {
     install -d ${D}${PTEST_PATH}/tests
     cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
+    # references the unshipped top-level 'scripts' package used by typer's release tooling
+    rm -f ${D}${PTEST_PATH}/tests/test_prepare_release.py
 }