From f16204f6fd43a82d4151f17a78d7cc38f278cc7c Mon Sep 17 00:00:00 2001
From: Benedek Racz <betontalpfa@gmail.com>
Date: Sun, 23 Feb 2020 11:31:14 +0100
Subject: [PATCH] [FIX] add workaround for #29, the disabled local_echo is not
 stable.

---
 tests/test_expect.py | 69 ++++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 31 deletions(-)

diff --git a/tests/test_expect.py b/tests/test_expect.py
index d1b0180..dd2dc1d 100644
--- a/tests/test_expect.py
+++ b/tests/test_expect.py
@@ -109,13 +109,13 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
         (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
         '''
-        p = wexpect.spawn('cat', timeout=5, echo=False)
+        p = wexpect.spawn('cat', timeout=5, echo=True)
         self._expect_order(p)
 
     def test_expect_order_exact (self):
         '''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
         self._expect_order(p)
 
@@ -125,35 +125,42 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
         p.sendline ('wxyz')
         p.sendline ('7890')
         p.sendeof ()
-        index = p.expect ([
-            '1234',
-            'abcd',
-            'wxyz',
-            wexpect.EOF,
-            '7890' ])
-        self.assertEqual(index,  0, (index, p.before, p.after))
-        index = p.expect ([
-            '54321',
-            wexpect.TIMEOUT,
-            '1234',
-            'abcd',
-            'wxyz',
-            wexpect.EOF], timeout=5)
-        self.assertEqual(index,  3, (index, p.before, p.after))
-        index = p.expect ([
-            '54321',
-            wexpect.TIMEOUT,
-            '1234',
-            'abcd',
-            'wxyz',
-            wexpect.EOF], timeout=5)
-        self.assertEqual(index,  4, (index, p.before, p.after))
-        index = p.expect ([
-            wexpect.EOF,
-            'abcd',
-            'wxyz',
-            '7890' ])
-        self.assertEqual(index,  3, (index, p.before, p.after))
+        for _ in range(2):
+            index = p.expect ([
+                '1234',
+                'abcd',
+                'wxyz',
+                wexpect.EOF,
+                '7890' ])
+            self.assertEqual(index,  0, (index, p.before, p.after))
+
+        for _ in range(2):
+            index = p.expect ([
+                '54321',
+                wexpect.TIMEOUT,
+                '1234',
+                'abcd',
+                'wxyz',
+                wexpect.EOF], timeout=5)
+            self.assertEqual(index,  3, (index, p.before, p.after))
+
+        for _ in range(2):
+            index = p.expect ([
+                '54321',
+                wexpect.TIMEOUT,
+                '1234',
+                'abcd',
+                'wxyz',
+                wexpect.EOF], timeout=5)
+            self.assertEqual(index,  4, (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 ([
             'abcd',