Skip to content

Commit acc4b8f

Browse files
committed
Handle no readline on Windows
1 parent ec011d4 commit acc4b8f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/_pytest/capture.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ def _readline_workaround() -> None:
9191
workaround consists of importing readline here, so we already worked around
9292
the issue by the time we could check if we need to.
9393
"""
94-
import readline # noqa: F401
94+
try:
95+
import readline # noqa: F401
96+
except ImportError:
97+
pass
9598

9699

97100
def _windowsconsoleio_workaround(stream: TextIO) -> None:

testing/test_capture.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,8 +1684,7 @@ def pytest_terminal_summary(config):
16841684
16851685
capture.resume_global_capture()
16861686
""")
1687-
import readline
1688-
1687+
readline = pytest.importorskip("readline")
16891688
backend = getattr(readline, "backend", readline.__doc__) # added in Python 3.13
16901689
print(f"Readline backend: {backend}")
16911690

0 commit comments

Comments
 (0)