diff options
author | dluyer <53582923+dluyer@users.noreply.github.com> | 2020-01-10 15:20:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-10 15:20:34 -0800 |
commit | 5eab9f4b01d586420546448fd4838315062fdbad (patch) | |
tree | d68e0796d437cbac7a2121dd34b30359d5f998de | |
parent | cf821ce4e3960fda579d8dad16ebb68f37a75128 (diff) | |
download | pexpect-git-5eab9f4b01d586420546448fd4838315062fdbad.tar.gz |
Add test for increasing searchwindowsize
-rwxr-xr-x | tests/test_expect.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/test_expect.py b/tests/test_expect.py index e4d023f..dc768a0 100755 --- a/tests/test_expect.py +++ b/tests/test_expect.py @@ -452,21 +452,40 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase): self._before_after(p) def test_before_after_timeout(self): + '''Tests that before is not truncated after a timeout, a bug in 4.7.''' child = pexpect.spawn('cat', echo=False) child.sendline('BEGIN') for i in range(100): child.sendline('foo' * 100) - e = child.expect(['xyzzy', pexpect.TIMEOUT], + e = child.expect([b'xyzzy', pexpect.TIMEOUT], searchwindowsize=10, timeout=0.001) self.assertEqual(e, 1) child.sendline('xyzzy') - e = child.expect(['xyzzy', pexpect.TIMEOUT], + e = child.expect([b'xyzzy', pexpect.TIMEOUT], searchwindowsize=10, timeout=30) self.assertEqual(e, 0) self.assertEqual(child.before[0:5], b'BEGIN') child.sendeof() child.expect(pexpect.EOF) + def test_increasing_searchwindowsize(self): + '''Tests that the search window can be expanded, a bug in 4.7.''' + child = pexpect.spawn('cat', echo=False) + child.sendline('BEGIN') + for i in range(100): + child.sendline('foo' * 100) + e = child.expect([b'xyzzy', pexpect.TIMEOUT], + searchwindowsize=10, timeout=0.5) + self.assertEqual(e, 1) + e = child.expect([b'BEGIN', pexpect.TIMEOUT], + searchwindowsize=10, timeout=0.5) + self.assertEqual(e, 1) + e = child.expect([b'BEGIN', pexpect.TIMEOUT], + searchwindowsize=40000, timeout=30.0) + self.assertEqual(e, 0) + child.sendeof() + child.expect(pexpect.EOF) + def _ordering(self, p): p.timeout = 20 p.expect(b'>>> ') |