diff options
author | dluyer <53582923+dluyer@users.noreply.github.com> | 2020-01-10 11:45:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-10 11:45:35 -0800 |
commit | 2bbb684cb399bbe203fe6a7103640d77b5c4a580 (patch) | |
tree | 30e42910530b2f93e24606a44330e3c31df91a47 | |
parent | c58e7e7d52a3f4471baf24748ffb0fb12526f686 (diff) | |
download | pexpect-2bbb684cb399bbe203fe6a7103640d77b5c4a580.tar.gz |
Add test for truncation issue fixed in #579
-rwxr-xr-x | tests/test_expect.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/test_expect.py b/tests/test_expect.py index c62231a..8a8c595 100755 --- a/tests/test_expect.py +++ b/tests/test_expect.py @@ -441,7 +441,7 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase): ''' p = pexpect.spawn('%s -Wi list100.py' % self.PYTHONBIN, env=no_coverage_env()) self._before_after(p) - + def test_before_after_exact(self): '''This tests some simple before/after things, for expect_exact(). (Grahn broke it at one point.) @@ -451,6 +451,22 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase): p.expect = p.expect_exact self._before_after(p) + def test_before_after_timeout(self): + child = pexpect.spawn('cat', echo=False) + child.sendline('BEGIN') + for i in range(100): + child.sendline('foo' * 100) + e = child.expect(['xyzzy', pexpect.TIMEOUT], + searchwindowsize=10, timeout=0.001) + self.assertEqual(e, 1) + child.sendline('xyzzy') + e = child.expect(['xyzzy', pexpect.TIMEOUT], + searchwindowsize=10, timeout=30) + self.assertEqual(e, 0) + self.assertEqual(child.before[0:5], 'BEGIN') + child.sendeof() + child.expect(pexpect.EOF) + def _ordering(self, p): p.timeout = 20 p.expect(b'>>> ') |