[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,35 +125,42 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
p.sendline ('wxyz') p.sendline ('wxyz')
p.sendline ('7890') p.sendline ('7890')
p.sendeof () p.sendeof ()
index = p.expect ([ for _ in range(2):
'1234', index = p.expect ([
'abcd', '1234',
'wxyz', 'abcd',
wexpect.EOF, 'wxyz',
'7890' ]) wexpect.EOF,
self.assertEqual(index, 0, (index, p.before, p.after)) '7890' ])
index = p.expect ([ self.assertEqual(index, 0, (index, p.before, p.after))
'54321',
wexpect.TIMEOUT, for _ in range(2):
'1234', index = p.expect ([
'abcd', '54321',
'wxyz', wexpect.TIMEOUT,
wexpect.EOF], timeout=5) '1234',
self.assertEqual(index, 3, (index, p.before, p.after)) 'abcd',
index = p.expect ([ 'wxyz',
'54321', wexpect.EOF], timeout=5)
wexpect.TIMEOUT, self.assertEqual(index, 3, (index, p.before, p.after))
'1234',
'abcd', for _ in range(2):
'wxyz', index = p.expect ([
wexpect.EOF], timeout=5) '54321',
self.assertEqual(index, 4, (index, p.before, p.after)) wexpect.TIMEOUT,
index = p.expect ([ '1234',
wexpect.EOF, 'abcd',
'abcd', 'wxyz',
'wxyz', wexpect.EOF], timeout=5)
'7890' ]) self.assertEqual(index, 4, (index, p.before, p.after))
self.assertEqual(index, 3, (index, p.before, p.after))
for _ in range(2):
index = p.expect ([
wexpect.EOF,
'abcd',
'wxyz',
'7890' ])
self.assertEqual(index, 3, (index, p.before, p.after))
index = p.expect ([ index = p.expect ([
'abcd', 'abcd',