Skip to content

some tets will fail like test_pyrepl when can't use pyrepl #139445

@yihong0618

Description

@yihong0618

This issue found when doing 139380

hyideMacBook-Pro:cpython hyi$ export TERM=unknown
hyideMacBook-Pro:cpython hyi$ ./python.exe 
No entry for terminal type "unknown";
using dumb terminal settings.
Python 3.15.0a0 (heads/main-dirty:89b5571025, Sep 30 2025, 14:22:39) [Clang 17.0.0 (clang-1700.0.13.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: (5, "terminal doesn't have the required clear capability"); TERM=unknown
Image

will fail and with pdb remote and curser test
./python.exe -m unittest test.test_pyrepl

after some dig the code in test_pyrepl.py _run_repl maybe not fullly right.

        if skip and "can't use pyrepl" in output:
            self.skipTest("pyrepl not available")
        return output, exit_code

the fix can solve the problem in pyrepl

diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index 47d384a209..c7a6a1392b 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -139,6 +139,14 @@ def _run_repl(
                 if exit_on_output in output[0]:
                     process.kill()
                     break
+            if "can't use pyrepl" in "".join(output):
+                os.close(master_fd)
+                process.kill()
+                try:
+                    process.wait(timeout=timeout)
+                except subprocess.TimeoutExpired:
+                    pass
+                self.skipTest("pyrepl not available")
         else:
             os.close(master_fd)
             process.kill()
@@ -1654,6 +1662,7 @@ def test_not_wiping_history_file(self):
         import_module('readline')
 
         hfile = tempfile.NamedTemporaryFile(delete=False)
+        self.addCleanup(hfile.close)
         self.addCleanup(unlink, hfile.name)
         env = os.environ.copy()
         env["PYTHON_HISTORY"] = hfile.name

others not solve(pdb remote on mac cursers.)

the fix is not simple so only the dig and the issue here.
Thanks

cc @picnixz

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirtopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions