Skip to content

Commit

Permalink
Handle no readline on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed Jan 31, 2025
1 parent ec011d4 commit acc4b8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/_pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def _readline_workaround() -> None:
workaround consists of importing readline here, so we already worked around
the issue by the time we could check if we need to.
"""
import readline # noqa: F401
try:
import readline # noqa: F401
except ImportError:
pass


def _windowsconsoleio_workaround(stream: TextIO) -> None:
Expand Down
3 changes: 1 addition & 2 deletions testing/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,8 +1684,7 @@ def pytest_terminal_summary(config):
capture.resume_global_capture()
""")
import readline

readline = pytest.importorskip("readline")
backend = getattr(readline, "backend", readline.__doc__) # added in Python 3.13
print(f"Readline backend: {backend}")

Expand Down

0 comments on commit acc4b8f

Please sign in to comment.