Skip to content

Commit e800dca

Browse files
committed
Changed REPLWrapper to accept args argument
1 parent 2de5d37 commit e800dca

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

metakernel/replwrap.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class REPLWrapper(object):
4747
we need to interrupt a continuation prompt.
4848
:param bool echo: Whether the child should echo, or in the case
4949
of Windows, whether the child does echo.
50+
:param list args: Additional arguments to the spawning command
5051
"""
5152

5253
def __init__(self, cmd_or_spawn, prompt_regex, prompt_change_cmd,
@@ -56,9 +57,10 @@ def __init__(self, cmd_or_spawn, prompt_regex, prompt_change_cmd,
5657
extra_init_cmd=None,
5758
prompt_emit_cmd=None,
5859
force_prompt_on_continuation=False,
59-
echo=False):
60+
echo=False,
61+
args=[]):
6062
if isinstance(cmd_or_spawn, basestring):
61-
self.child = pexpect.spawnu(cmd_or_spawn, echo=echo,
63+
self.child = pexpect.spawnu(cmd_or_spawn, args, echo=echo,
6264
codec_errors="ignore",
6365
encoding="utf-8")
6466
else:

metakernel/tests/test_replwrap.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ def test_bracketed_paste(self):
9595
res = bash.run_command("echo '1 2\n3 4'")
9696
self.assertEqual(res.strip().splitlines(), ['1 2', '3 4'])
9797

98+
def test_spawn_args(self):
99+
p = replwrap.REPLWrapper(sys.executable, ">>> ",
100+
"import sys; sys.ps1={0!r}; sys.ps2={1!r}",
101+
args=['-i', '-c', 'x=4+7'])
102+
res = p.run_command('x-11')
103+
assert res.strip() == '0'
104+
98105

99106
if __name__ == '__main__':
100107
unittest.main()

0 commit comments

Comments
 (0)