mirror of
https://github.com/clearml/wexpect-venv
synced 2025-03-03 18:51:55 +00:00
[REF] spawn renamed to host not to hide spawn class; [FIX][TST] More misc test fixed
This commit is contained in:
parent
e62dfabc82
commit
fa38c44947
@ -198,10 +198,11 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
||||
def test_isalive(self):
|
||||
" check isalive() before and after EOF. (True, False) "
|
||||
child = wexpect.spawn('cat')
|
||||
assert child.isalive() is True
|
||||
self.assertTrue(child.isalive())
|
||||
child.sendeof()
|
||||
child.expect(wexpect.EOF)
|
||||
assert child.isalive() is False
|
||||
time.sleep(.5)
|
||||
self.assertFalse(child.isalive())
|
||||
|
||||
def test_bad_type_in_expect(self):
|
||||
" expect() does not accept dictionary arguments. "
|
||||
@ -235,14 +236,14 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
||||
# given,
|
||||
given_words = ['alpha', 'beta', 'gamma', 'delta', ]
|
||||
given_search = given_words
|
||||
if searcher == wexpect.searcher_re:
|
||||
if searcher == wexpect.host.searcher_re:
|
||||
given_search = [re.compile(word) for word in given_words]
|
||||
if plus is not None:
|
||||
given_search = given_search + [plus]
|
||||
search_string = searcher(given_search)
|
||||
basic_fmt = '\n {0}: {1}'
|
||||
fmt = basic_fmt
|
||||
if searcher is wexpect.searcher_re:
|
||||
if searcher is wexpect.host.searcher_re:
|
||||
fmt = '\n {0}: re.compile({1})'
|
||||
expected_output = '{0}:'.format(searcher.__name__)
|
||||
idx = 0
|
||||
@ -260,27 +261,27 @@ class TestCaseMisc(PexpectTestCase.PexpectTestCase):
|
||||
|
||||
def test_searcher_as_string(self):
|
||||
" check searcher_string(..).__str__() "
|
||||
self._test_searcher_as(wexpect.searcher_string)
|
||||
self._test_searcher_as(wexpect.host.searcher_string)
|
||||
|
||||
def test_searcher_as_string_with_EOF(self):
|
||||
" check searcher_string(..).__str__() that includes EOF "
|
||||
self._test_searcher_as(wexpect.searcher_string, plus=wexpect.EOF)
|
||||
self._test_searcher_as(wexpect.host.searcher_string, plus=wexpect.EOF)
|
||||
|
||||
def test_searcher_as_string_with_TIMEOUT(self):
|
||||
" check searcher_string(..).__str__() that includes TIMEOUT "
|
||||
self._test_searcher_as(wexpect.searcher_string, plus=wexpect.TIMEOUT)
|
||||
self._test_searcher_as(wexpect.host.searcher_string, plus=wexpect.TIMEOUT)
|
||||
|
||||
def test_searcher_re_as_string(self):
|
||||
" check searcher_re(..).__str__() "
|
||||
self._test_searcher_as(wexpect.searcher_re)
|
||||
self._test_searcher_as(wexpect.host.searcher_re)
|
||||
|
||||
def test_searcher_re_as_string_with_EOF(self):
|
||||
" check searcher_re(..).__str__() that includes EOF "
|
||||
self._test_searcher_as(wexpect.searcher_re, plus=wexpect.EOF)
|
||||
self._test_searcher_as(wexpect.host.searcher_re, plus=wexpect.EOF)
|
||||
|
||||
def test_searcher_re_as_string_with_TIMEOUT(self):
|
||||
" check searcher_re(..).__str__() that includes TIMEOUT "
|
||||
self._test_searcher_as(wexpect.searcher_re, plus=wexpect.TIMEOUT)
|
||||
self._test_searcher_as(wexpect.host.searcher_re, plus=wexpect.TIMEOUT)
|
||||
|
||||
def test_exception_tb(self):
|
||||
" test get_trace() filters away wexpect/__init__.py calls. "
|
||||
|
@ -11,9 +11,9 @@ from .wexpect_util import TIMEOUT
|
||||
from .console_reader import ConsoleReaderSocket
|
||||
from .console_reader import ConsoleReaderPipe
|
||||
|
||||
from .spawn import SpawnSocket
|
||||
from .spawn import SpawnPipe
|
||||
from .spawn import run
|
||||
from .host import SpawnSocket
|
||||
from .host import SpawnPipe
|
||||
from .host import run
|
||||
|
||||
try:
|
||||
spawn_class_name = os.environ['WEXPECT_SPAWN_CLASS']
|
||||
|
@ -46,7 +46,6 @@ import psutil
|
||||
from io import StringIO
|
||||
|
||||
import ctypes
|
||||
import pywintypes
|
||||
import win32console
|
||||
import win32process
|
||||
import win32con
|
||||
|
@ -381,7 +381,7 @@ class SpawnBase:
|
||||
logger.info(f'Console starter command:{commandLine}')
|
||||
|
||||
_, _, self.console_pid, __otid = win32process.CreateProcess(None, commandLine, None, None, False,
|
||||
win32process.CREATE_NEW_CONSOLE, None, None, si)
|
||||
win32process.CREATE_NEW_CONSOLE, None, self.cwd, si)
|
||||
|
||||
def get_console_process(self, force=False):
|
||||
if force or self.console_process is None:
|
||||
@ -409,6 +409,11 @@ class SpawnBase:
|
||||
continue
|
||||
self.child_pid = self.child_process.pid
|
||||
return self.child_process
|
||||
|
||||
def close(self): # File-like object.
|
||||
""" Closes the child console."""
|
||||
|
||||
self.closed = self.terminate()
|
||||
|
||||
def terminate(self, force=False):
|
||||
"""Terminate the child. Force not used. """
|
||||
@ -946,7 +951,7 @@ class SpawnSocket(SpawnBase):
|
||||
self.port = port
|
||||
self.host = host
|
||||
self.sock = None
|
||||
self.console_class_name = 'ConsoleReaderPipe'
|
||||
self.console_class_name = 'ConsoleReaderSocket'
|
||||
self.console_class_parameters = {'port': port}
|
||||
|
||||
super().__init__(command=command, args=args, timeout=timeout, maxread=maxread,
|
@ -162,7 +162,7 @@ class ExceptionPexpect(Exception):
|
||||
def __filter_not_wexpect(self, trace_list_item):
|
||||
"""This returns True if list item 0 the string 'wexpect.py' in it. """
|
||||
|
||||
if trace_list_item[0].find('spawn.py') == -1:
|
||||
if trace_list_item[0].find('host.py') == -1:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user