Skip to content

Commit 4de3631

Browse files
committed
Isolate tests from personal Readline init files using INPUTRC=/dev/null trick
1 parent 572c780 commit 4de3631

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Lib/test/support/pty_helper.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@
1010

1111
from test.support.import_helper import import_module
1212

13-
def run_pty(script, input=b"dummy input\r", env=None):
13+
def run_pty(script, input=b"dummy input\r", env=None, readline=None):
1414
pty = import_module('pty')
1515
output = bytearray()
1616
[master, slave] = pty.openpty()
1717
args = (sys.executable, '-c', script)
18+
19+
if readline is None:
20+
readline = "readline" in sys.modules
21+
if readline:
22+
# Isolate readline from personal init files by setting INPUTRC
23+
# to an empty file. See also GH-142353.
24+
if env is None:
25+
env = {**os.environ.copy(), "INPUTRC": os.devnull}
26+
else:
27+
env.setdefault("INPUTRC", os.devnull)
28+
1829
proc = subprocess.Popen(args, stdin=slave, stdout=slave, stderr=slave, env=env)
1930
os.close(slave)
2031
with ExitStack() as cleanup:

0 commit comments

Comments
 (0)