summaryrefslogtreecommitdiff
path: root/tests/test_replwrap.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_replwrap.py')
-rw-r--r--tests/test_replwrap.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/test_replwrap.py b/tests/test_replwrap.py
index 28c7599..6e56af0 100644
--- a/tests/test_replwrap.py
+++ b/tests/test_replwrap.py
@@ -6,6 +6,8 @@ import os
import pexpect
from pexpect import replwrap
+skip_pypy = "This test fails on PyPy because of REPL differences"
+
class REPLWrapTestCase(unittest.TestCase):
def setUp(self):
@@ -25,10 +27,24 @@ class REPLWrapTestCase(unittest.TestCase):
res = bash.run_command("time")
assert 'real' in res, res
- # PAGER should be set to cat, otherwise man hangs
+ def test_pager_as_cat(self):
+ " PAGER is set to cat, to prevent timeout in ``man sleep``. "
+ bash = replwrap.bash()
res = bash.run_command('man sleep', timeout=5)
assert 'SLEEP' in res, res
+ def test_long_running_multiline(self):
+ " ensure the default timeout is used for multi-line commands. "
+ bash = replwrap.bash()
+ res = bash.run_command("echo begin\r\nsleep 2\r\necho done")
+ self.assertEqual(res.strip().splitlines(), ['begin', 'done'])
+
+ def test_long_running_continuation(self):
+ " also ensure timeout when used within continuation prompts. "
+ bash = replwrap.bash()
+ res = bash.run_command("echo begin\\\n;sleep 2\r\necho done")
+ self.assertEqual(res.strip().splitlines(), ['begin', 'done'])
+
def test_multiline(self):
bash = replwrap.bash()
res = bash.run_command("echo '1 2\n3 4'")
@@ -57,7 +73,7 @@ class REPLWrapTestCase(unittest.TestCase):
def test_python(self):
if platform.python_implementation() == 'PyPy':
- raise unittest.SkipTest("This test fails on PyPy because of REPL differences")
+ raise unittest.SkipTest(skip_pypy)
p = replwrap.python()
res = p.run_command('4+7')
@@ -68,7 +84,7 @@ class REPLWrapTestCase(unittest.TestCase):
def test_no_change_prompt(self):
if platform.python_implementation() == 'PyPy':
- raise unittest.SkipTest("This test fails on PyPy because of REPL differences")
+ raise unittest.SkipTest(skip_pypy)
child = pexpect.spawnu('python', echo=False, timeout=5)
# prompt_change=None should mean no prompt change
@@ -79,6 +95,5 @@ class REPLWrapTestCase(unittest.TestCase):
res = py.run_command("for a in range(3): print(a)\n")
assert res.strip().splitlines() == ['0', '1', '2']
-
if __name__ == '__main__':
unittest.main()