aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
diff options
context:
space:
mode:
authorEbuka Ezike <yerimyah1@gmail.com>2026-01-26 22:20:55 +0000
committerGitHub <noreply@github.com>2026-01-26 22:20:55 +0000
commit78f9d78b13423ecfc354579ef00599f68e0f5b88 (patch)
treea735e0e2e4cab9b2663f71f0c056b8a9a7c88ec5 /lldb/test/API/python_api
parent460c9b2db144e4ef736a31f29c0b366e565f2574 (diff)
downloadllvm-78f9d78b13423ecfc354579ef00599f68e0f5b88.zip
llvm-78f9d78b13423ecfc354579ef00599f68e0f5b88.tar.gz
llvm-78f9d78b13423ecfc354579ef00599f68e0f5b88.tar.bz2
[lldb] Fix Python stderr redirection in test (#177970)
Python's internal stderr may differ from sys.stderr. When Python writes errors, it uses its internal stderr rather than the overwritten sys.stderr. This may not be the same file/handle Fix the test to explicitly write to the specified stderr.
Diffstat (limited to 'lldb/test/API/python_api')
-rw-r--r--lldb/test/API/python_api/file_handle/TestFileHandle.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lldb/test/API/python_api/file_handle/TestFileHandle.py b/lldb/test/API/python_api/file_handle/TestFileHandle.py
index 70720e3..eba758f 100644
--- a/lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ b/lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -684,7 +684,13 @@ class FileHandleTestCase(lldbtest.TestBase):
"""Ensure when we read stdin from a file, outputs from python goes to the right I/O stream."""
with open(self.in_filename, "w") as f:
f.write(
- "script --language python --\nvalue = 250 + 5\nprint(value)\nprint(vel)"
+ """script --language python --
+import sys
+variable = 250 + 5
+print(variable)
+print("wrote to", "stderr", file=sys.stderr)
+quit
+"""
)
with open(self.out_filename, "w") as outf, open(
@@ -712,7 +718,7 @@ class FileHandleTestCase(lldbtest.TestBase):
)
self.dbg.GetOutputFile().Flush()
expected_out_text = "255"
- expected_err_text = "NameError"
+ expected_err_text = "wrote to stderr"
# check stdout
with open(self.out_filename, "r") as f:
out_text = f.read()