mirror of
https://github.com/clearml/wexpect-venv
synced 2025-01-30 18:36:57 +00:00
[FIX] EOF handling moved upper to handle exception of last characters' patterns
This commit is contained in:
parent
96987d4030
commit
3ba138a6fc
@ -8,7 +8,6 @@ import os
|
||||
|
||||
import wexpect
|
||||
from tests import PexpectTestCase
|
||||
from .utils import no_coverage_env
|
||||
|
||||
# Many of these test cases blindly assume that sequential directory
|
||||
# listings of the /bin directory will yield the same results.
|
||||
@ -279,14 +278,14 @@ class ExpectTestCase (PexpectTestCase.PexpectTestCase):
|
||||
def test_before_after(self):
|
||||
'''This tests expect() for some simple before/after things.
|
||||
'''
|
||||
p = wexpect.spawn('%s -Wi list100.py' % PYTHONBINQUOTE, env=no_coverage_env())
|
||||
p = wexpect.spawn('%s -Wi list100.py' % PYTHONBINQUOTE)
|
||||
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.)
|
||||
'''
|
||||
p = wexpect.spawn('%s -Wi list100.py' % PYTHONBINQUOTE, env=no_coverage_env())
|
||||
p = wexpect.spawn('%s -Wi list100.py' % PYTHONBINQUOTE)
|
||||
# mangle the spawn so we test expect_exact() instead
|
||||
p.expect = p.expect_exact
|
||||
self._before_after(p)
|
||||
|
@ -814,6 +814,8 @@ class SpawnBase:
|
||||
self.match_index = index
|
||||
return self.match_index
|
||||
# No match at this point
|
||||
if self.flag_eof:
|
||||
raise EOF('EOF flag has been raised.')
|
||||
if timeout is not None and end_time < time.time():
|
||||
logger.info('Timeout exceeded in expect_any().')
|
||||
raise TIMEOUT('Timeout exceeded in expect_any().')
|
||||
@ -932,10 +934,10 @@ class SpawnPipe(SpawnBase):
|
||||
else:
|
||||
logger.spam(f'Readed: {s}')
|
||||
|
||||
if b'\x04' in s:
|
||||
if EOF_CHAR in s:
|
||||
self.flag_eof = True
|
||||
logger.info("EOF: EOF character has been arrived")
|
||||
raise EOF('EOF character has been arrived')
|
||||
s = s.split(EOF_CHAR)[0]
|
||||
|
||||
return s.decode()
|
||||
except pywintypes.error as e:
|
||||
@ -1052,7 +1054,7 @@ class SpawnSocket(SpawnBase):
|
||||
if EOF_CHAR in s:
|
||||
self.flag_eof = True
|
||||
logger.info("EOF: EOF character has been arrived")
|
||||
raise EOF('EOF character has been arrived')
|
||||
s = s.split(EOF_CHAR)[0]
|
||||
|
||||
except ConnectionResetError:
|
||||
self.flag_eof = True
|
||||
|
Loading…
Reference in New Issue
Block a user