diff mbox series

[whinlatter] python3: Fix test under ptest-runner 2.5.1

Message ID 20260417075943.1398549-1-yoann.congal@smile.fr
State Accepted, archived
Delegated to: Yoann Congal
Headers show
Series [whinlatter] python3: Fix test under ptest-runner 2.5.1 | expand

Commit Message

Yoann Congal April 17, 2026, 7:59 a.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

test_cmd_line.test_non_interactive_output_buffering assumes a buffered
stdio. But since ptest-runner 2.5.0, PYTHONUNBUFFERED=1 is used, stdio
is not buffered and the test fails.

Backport a patch to skip this test when PYTHONUNBUFFERED=1.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 ...est_cmd_line.test_non_interactive_ou.patch | 31 +++++++++++++++++++
 .../python/python3_3.13.12.bb                 |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3/0001-gh-128377-Skip-test_cmd_line.test_non_interactive_ou.patch
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3/0001-gh-128377-Skip-test_cmd_line.test_non_interactive_ou.patch b/meta/recipes-devtools/python/python3/0001-gh-128377-Skip-test_cmd_line.test_non_interactive_ou.patch
new file mode 100644
index 00000000000..9604a3c8402
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/0001-gh-128377-Skip-test_cmd_line.test_non_interactive_ou.patch
@@ -0,0 +1,31 @@ 
+From 8d02dc113f4498ca7142c17a8698b8b276cd8a5b Mon Sep 17 00:00:00 2001
+From: Yan Yanchii <yyanchiy@gmail.com>
+Date: Sun, 12 Jan 2025 09:27:28 +0100
+Subject: [PATCH] gh-128377: Skip
+ `test_cmd_line.test_non_interactive_output_buffering` when
+ `PYTHONUNBUFFERED=1` (#128378)
+
+
+The `test_cmd_line.test_non_interactive_output_buffering` test assumes a buffered `stdio`
+without checking the `PYTHONUNBUFFERED` value. Instead of changing the environment
+variable for the duration of the test, it is better to simply skip it.
+
+Upstream-Status: Backport [https://github.com/python/cpython/commit/30268b5d2fbb1a5e6c876f0cdc4cbdb5d93315e6]
+Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
+---
+ Lib/test/test_cmd_line.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
+index dc420f33c23..ef24866972a 100644
+--- a/Lib/test/test_cmd_line.py
++++ b/Lib/test/test_cmd_line.py
+@@ -334,6 +334,8 @@ class CmdLineTest(unittest.TestCase):
+         self.assertEqual(stdout, expected)
+         self.assertEqual(p.returncode, 0)
+ 
++    @unittest.skipIf(os.environ.get("PYTHONUNBUFFERED", "0") != "0",
++                     "Python stdio buffering is disabled.")
+     def test_non_interactive_output_buffering(self):
+         code = textwrap.dedent("""
+             import sys
diff --git a/meta/recipes-devtools/python/python3_3.13.12.bb b/meta/recipes-devtools/python/python3_3.13.12.bb
index e30acebe20d..854d8341354 100644
--- a/meta/recipes-devtools/python/python3_3.13.12.bb
+++ b/meta/recipes-devtools/python/python3_3.13.12.bb
@@ -31,6 +31,7 @@  SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
            file://0001-test_readline-skip-limited-history-test.patch \
            file://0001-Generate-data-for-OpenSSL-3.4-and-add-it-to-multissl.patch \
            file://0001-Skip-flaky-test_default_timeout-tests.patch \
+           file://0001-gh-128377-Skip-test_cmd_line.test_non_interactive_ou.patch \
            "
 SRC_URI:append:class-native = " \
            file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \