diff --git a/tests/test_expect.py b/tests/test_expect.py index 56f0a34..1eefae5 100644 --- a/tests/test_expect.py +++ b/tests/test_expect.py @@ -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) diff --git a/wexpect/host.py b/wexpect/host.py index 9ac1b5e..d0b0653 100644 --- a/wexpect/host.py +++ b/wexpect/host.py @@ -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