summaryrefslogtreecommitdiff
path: root/tests/test_replwrap.py
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 /tests/test_replwrap.py
parent01f85224232f416890576348cfc6ba31f8a7e22e (diff)
downloadpexpect-git-9c97dca35965751812b992dda2eb1433d4206c68.tar.gz
Use bash for testing replwrap, avoiding PyPy's different REPL
Diffstat (limited to 'tests/test_replwrap.py')
-rw-r--r--tests/test_replwrap.py30
1 files changed, 15 insertions, 15 deletions
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