[FIX] add workaround for #29, the disabled local_echo is not stable.

This commit is contained in:
Benedek Racz 2020-02-23 11:31:14 +01:00
parent 22b2e2ea92
commit f16204f6fd

View File

@ -109,13 +109,13 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
(one of the) the leftmost matches in the input? -- grahn) (one of the) the leftmost matches in the input? -- grahn)
... agreed! -jquast, the buffer ptr isn't forwarded on match, see first two test cases ... agreed! -jquast, the buffer ptr isn't forwarded on match, see first two test cases
''' '''
p = wexpect.spawn('cat', timeout=5, echo=False) p = wexpect.spawn('cat', timeout=5, echo=True)
self._expect_order(p) self._expect_order(p)
def test_expect_order_exact (self): def test_expect_order_exact (self):
'''Like test_expect_order(), but using expect_exact(). '''Like test_expect_order(), but using expect_exact().
''' '''
p = wexpect.spawn('cat', timeout=5, echo=False) p = wexpect.spawn('cat', timeout=5, echo=True)
p.expect = p.expect_exact p.expect = p.expect_exact
self._expect_order(p) self._expect_order(p)
@ -125,6 +125,7 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
p.sendline ('wxyz') p.sendline ('wxyz')
p.sendline ('7890') p.sendline ('7890')
p.sendeof () p.sendeof ()
for _ in range(2):
index = p.expect ([ index = p.expect ([
'1234', '1234',
'abcd', 'abcd',
@ -132,6 +133,8 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
wexpect.EOF, wexpect.EOF,
'7890' ]) '7890' ])
self.assertEqual(index, 0, (index, p.before, p.after)) self.assertEqual(index, 0, (index, p.before, p.after))
for _ in range(2):
index = p.expect ([ index = p.expect ([
'54321', '54321',
wexpect.TIMEOUT, wexpect.TIMEOUT,
@ -140,6 +143,8 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
'wxyz', 'wxyz',
wexpect.EOF], timeout=5) wexpect.EOF], timeout=5)
self.assertEqual(index, 3, (index, p.before, p.after)) self.assertEqual(index, 3, (index, p.before, p.after))
for _ in range(2):
index = p.expect ([ index = p.expect ([
'54321', '54321',
wexpect.TIMEOUT, wexpect.TIMEOUT,
@ -148,6 +153,8 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
'wxyz', 'wxyz',
wexpect.EOF], timeout=5) wexpect.EOF], timeout=5)
self.assertEqual(index, 4, (index, p.before, p.after)) self.assertEqual(index, 4, (index, p.before, p.after))
for _ in range(2):
index = p.expect ([ index = p.expect ([
wexpect.EOF, wexpect.EOF,
'abcd', 'abcd',