Skip to content

Commit 57bc14c

Browse files
committed
Apply readline workaround during initial conftest loading
1 parent 6e170a4 commit 57bc14c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

_pytest/capture.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def pytest_addoption(parser):
3131

3232
@pytest.hookimpl(hookwrapper=True)
3333
def pytest_load_initial_conftests(early_config, parser, args):
34+
_readline_workaround()
3435
ns = early_config.known_args_namespace
3536
pluginmanager = early_config.pluginmanager
3637
capman = CaptureManager(ns.capture)
@@ -307,8 +308,7 @@ class NoCapture:
307308
class FDCapture:
308309
""" Capture IO to/from a given os-level filedescriptor. """
309310

310-
def __init__(self, targetfd, tmpfile=None):
311-
readline_workaround()
311+
def __init__(self, targetfd, tmpfile=None):
312312
self.targetfd = targetfd
313313
try:
314314
self.targetfd_save = os.dup(self.targetfd)
@@ -445,7 +445,7 @@ def close(self):
445445
pass
446446

447447

448-
def readline_workaround():
448+
def _readline_workaround():
449449
"""
450450
Ensure readline is imported so that it attaches to the correct stdio
451451
handles on Windows.
@@ -464,6 +464,8 @@ def readline_workaround():
464464
See https://github.com/pytest-dev/pytest/pull/1281
465465
"""
466466

467+
if not sys.platform.startswith('win32'):
468+
return
467469
try:
468470
import readline # noqa
469471
except ImportError:

0 commit comments

Comments
 (0)