summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2018-03-27 10:17:30 -0400
committerRyan Petrello <lists@ryanpetrello.com>2018-03-27 10:42:40 -0400
commit5a2e63f3fbfb39458c832a65bf8db330e954b8f6 (patch)
treed5ba62f8c6b5801d81631eafd6a6342b5897eaf0 /tests
parent221cca0fec1763b486918d5c2c27e65477bf9290 (diff)
downloadpexpect-git-5a2e63f3fbfb39458c832a65bf8db330e954b8f6.tar.gz
fix a bug causing 'spawn.before' to be truncated w/ searchwindowsize use
see: https://github.com/pexpect/pexpect/issues/478
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_expect.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_expect.py b/tests/test_expect.py
index ec55d43..795518a 100755
--- a/tests/test_expect.py
+++ b/tests/test_expect.py
@@ -408,6 +408,17 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
p.buffer = b'Testing'
p.sendeof ()
+ def test_before_across_chunks(self):
+ # https://github.com/pexpect/pexpect/issues/478
+ child = pexpect.spawn(
+ '''/bin/bash -c "openssl rand -base64 {} | head -500 | nl --number-format=rz --number-width=5 2>&1 ; echo 'PATTERN!!!'"'''.format(1024 * 1024 * 2),
+ searchwindowsize=128
+ )
+ child.expect(['PATTERN'])
+ assert len(child.before.splitlines()) == 500
+ assert child.after == b'PATTERN'
+ assert child.buffer == b'!!!\r\n'
+
def _before_after(self, p):
p.timeout = 5