summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Kluyver <takowl@gmail.com>2014-05-31 17:21:30 -0700
committerThomas Kluyver <takowl@gmail.com>2014-05-31 17:21:30 -0700
commit9c97dca35965751812b992dda2eb1433d4206c68 (patch)
tree69ff51fc66ff3620318fccc96422d94b2586942c
parent01f85224232f416890576348cfc6ba31f8a7e22e (diff)
downloadpexpect-9c97dca35965751812b992dda2eb1433d4206c68.tar.gz
Use bash for testing replwrap, avoiding PyPy's different REPL
-rw-r--r--pexpect/replwrap.py2
-rw-r--r--tests/test_replwrap.py30
2 files changed, 16 insertions, 16 deletions
diff --git a/pexpect/replwrap.py b/pexpect/replwrap.py
index 5d74a77..965c790 100644
--- a/pexpect/replwrap.py
+++ b/pexpect/replwrap.py
@@ -95,4 +95,4 @@ def python(command="python"):
def bash(command="bash", orig_prompt=u("$")):
"""Start a bash shell and return a :class:`REPLWrapper` object."""
- return REPLWrapper(command, orig_prompt, u("PS1={0!r}; PS2={1!r}"))
+ return REPLWrapper(command, orig_prompt, u("PS1='{0}'; PS2='{1}'"))
diff --git a/tests/test_replwrap.py b/tests/test_replwrap.py
index f38305c..835bf63 100644
--- a/tests/test_replwrap.py
+++ b/tests/test_replwrap.py
@@ -6,34 +6,34 @@ from pexpect import replwrap
class REPLWrapTestCase(unittest.TestCase):
def test_python(self):
- py = replwrap.python(sys.executable)
- res = py.run_command("5+6")
- self.assertEqual(res.strip(), "11")
+ bash = replwrap.bash()
+ res = bash.run_command("time")
+ assert 'real' in res, res
def test_multiline(self):
- py = replwrap.python(sys.executable)
- res = py.run_command("for a in range(3):\n print(a)\n")
- self.assertEqual(res.strip().splitlines(), ['0', '1', '2'])
+ bash = replwrap.bash()
+ res = bash.run_command("echo '1 2\n3 4'")
+ self.assertEqual(res.strip().splitlines(), ['1 2', '3 4'])
# Should raise ValueError if input is incomplete
try:
- py.run_command("for a in range(3):")
+ bash.run_command("echo '5 6")
except ValueError:
pass
else:
- assert False, "Didn't raise ValueError for incorrect input"
+ assert False, "Didn't raise ValueError for incomplete input"
# Check that the REPL was reset (SIGINT) after the incomplete input
- res = py.run_command("for a in range(3):\n print(a)\n")
- self.assertEqual(res.strip().splitlines(), ['0', '1', '2'])
+ res = bash.run_command("echo '1 2\n3 4'")
+ self.assertEqual(res.strip().splitlines(), ['1 2', '3 4'])
def test_existing_spawn(self):
- child = pexpect.spawnu("python")
- repl = replwrap.REPLWrapper(child, replwrap.u(">>> "),
- "import sys; sys.ps1={0!r}; sys.ps2={1!r}")
+ child = pexpect.spawnu("bash")
+ repl = replwrap.REPLWrapper(child, replwrap.u("$ "),
+ "PS1='{0}'; PS2='{1}'")
- res = repl.run_command("print(7*6)")
- self.assertEqual(res.strip(), "42")
+ res = repl.run_command("echo $HOME")
+ assert res.startswith('/'), res
if __name__ == '__main__':
unittest.main() \ No newline at end of file