gh-150544: Fix pdb _pyrepl_available() and make test_gen_colors skip at runtime#150545
Open
sendaoYan wants to merge 3 commits into
Open
gh-150544: Fix pdb _pyrepl_available() and make test_gen_colors skip at runtime#150545sendaoYan wants to merge 3 commits into
sendaoYan wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix pdb._pyrepl_available() so it checks the actual stdin/stdout streams (including TTY and fileno() support), not only the import-time CAN_USE_PYREPL flag.
Pass self.stdin and self.stdout from Pdb.init into _pyrepl_available().
Update test_gen_colors and PdbTestReadlinePyREPL to evaluate pyrepl availability at test runtime instead of via import-time @unittest.skipIf.
Harden test_pyrepl_available with explicit mock streams.
Fixes gh-150544
Problem
test.test_pdb.PdbTestColorize.test_gen_colors could fail with:
Changes
Extend _pyrepl_available(stdin=None, stdout=None) to:
honor PYTHON_BASIC_REPL and CAN_USE_PYREPL
verify stdin is a TTY at call time
verify both streams support fileno()
handle fake stdin objects (e.g. doctest FakeInput) without raising
Call _pyrepl_available(self.stdin, self.stdout) from Pdb.init
test_gen_colors: replace import-time @skipIf with runtime skipTest when pyrepl or pyrepl_input is unavailable
PdbTestReadlinePyREPL: use setUpClass for runtime skipping
test_pyrepl_available: test TTY and non-TTY cases using mock streams
Testing
All the cpython tests shows this PR do not cause new fails.