mirror of
https://github.com/clearml/wexpect-venv
synced 2025-06-26 18:15:52 +00:00
[FIX] align sleep times, now all commands arrives after the before one has been processed.[TST][FIX] destructor and constructor testcases
This commit is contained in:
parent
9709eb82e9
commit
eda36aa1a1
@ -42,8 +42,11 @@ class TestCaseConstructor(PexpectTestCase.PexpectTestCase):
|
||||
'''This tests that named parameters work.
|
||||
'''
|
||||
p = wexpect.spawn('ls',timeout=10)
|
||||
p.wait()
|
||||
p = wexpect.spawn(timeout=10, command='ls')
|
||||
p.wait()
|
||||
p = wexpect.spawn(args=[], command='ls')
|
||||
p.wait()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -32,19 +32,18 @@ class TestCaseDestructor(PexpectTestCase.PexpectTestCase):
|
||||
return 'SKIP'
|
||||
gc.collect()
|
||||
time.sleep(2)
|
||||
p1 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p2 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p3 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p4 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
fd_t1 = (p1.child_fd,p2.child_fd,p3.child_fd,p4.child_fd)
|
||||
p1 = wexpect.spawn('ls', port=4321)
|
||||
p2 = wexpect.spawn('ls', port=4322)
|
||||
p3 = wexpect.spawn('ls', port=4323)
|
||||
p4 = wexpect.spawn('ls', port=4324)
|
||||
p1.expect(wexpect.EOF)
|
||||
p2.expect(wexpect.EOF)
|
||||
p3.expect(wexpect.EOF)
|
||||
p4.expect(wexpect.EOF)
|
||||
p1.kill(9)
|
||||
p2.kill(9)
|
||||
p3.kill(9)
|
||||
p4.kill(9)
|
||||
p1.kill()
|
||||
p2.kill()
|
||||
p3.kill()
|
||||
p4.kill()
|
||||
p1 = None
|
||||
p2 = None
|
||||
p3 = None
|
||||
@ -52,15 +51,15 @@ class TestCaseDestructor(PexpectTestCase.PexpectTestCase):
|
||||
gc.collect()
|
||||
time.sleep(2) # Some platforms are slow at gc... Solaris!
|
||||
|
||||
p1 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p2 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p3 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p4 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
fd_t2 = (p1.child_fd,p2.child_fd,p3.child_fd,p4.child_fd)
|
||||
p1.kill(9)
|
||||
p2.kill(9)
|
||||
p3.kill(9)
|
||||
p4.kill(9)
|
||||
|
||||
p1 = wexpect.spawn('ls', port=4321)
|
||||
p2 = wexpect.spawn('ls', port=4322)
|
||||
p3 = wexpect.spawn('ls', port=4323)
|
||||
p4 = wexpect.spawn('ls', port=4324)
|
||||
p1.kill()
|
||||
p2.kill()
|
||||
p3.kill()
|
||||
p4.kill()
|
||||
del (p1)
|
||||
del (p2)
|
||||
del (p3)
|
||||
@ -68,13 +67,10 @@ class TestCaseDestructor(PexpectTestCase.PexpectTestCase):
|
||||
gc.collect()
|
||||
time.sleep(2)
|
||||
|
||||
p1 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p2 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p3 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
p4 = wexpect.spawn('"%s" hello_world.py' % self.PYTHONBIN)
|
||||
fd_t3 = (p1.child_fd,p2.child_fd,p3.child_fd,p4.child_fd)
|
||||
|
||||
assert (fd_t1 == fd_t2 == fd_t3), "pty file descriptors not properly garbage collected (fd_t1,fd_t2,fd_t3)=(%s,%s,%s)" % (str(fd_t1),str(fd_t2),str(fd_t3))
|
||||
p1 = wexpect.spawn('ls', port=4321)
|
||||
p2 = wexpect.spawn('ls', port=4322)
|
||||
p3 = wexpect.spawn('ls', port=4323)
|
||||
p4 = wexpect.spawn('ls', port=4324)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -175,7 +175,7 @@ class ConsoleReaderBase:
|
||||
self.resumeThread()
|
||||
paused = False
|
||||
|
||||
time.sleep(.1)
|
||||
time.sleep(.02)
|
||||
|
||||
def terminate_child(self):
|
||||
try:
|
||||
@ -437,7 +437,7 @@ class ConsoleReaderSocket(ConsoleReaderBase):
|
||||
self.sock.settimeout(5)
|
||||
self.sock.listen(1)
|
||||
self.connection, client_address = self.sock.accept()
|
||||
self.connection.settimeout(.2)
|
||||
self.connection.settimeout(.01)
|
||||
logger.info(f'Client connected: {client_address}')
|
||||
except:
|
||||
logger.error(f"Port: {self.port}")
|
||||
|
@ -990,6 +990,10 @@ class SpawnSocket(SpawnBase):
|
||||
except EOF:
|
||||
self.flag_eof = True
|
||||
raise
|
||||
except ConnectionResetError:
|
||||
self.flag_eof = True
|
||||
logger.info("EOF('ConnectionResetError')")
|
||||
raise EOF('ConnectionResetError')
|
||||
except socket.timeout:
|
||||
return ''
|
||||
|
||||
|
@ -44,7 +44,6 @@ import os
|
||||
import logging
|
||||
|
||||
def init_logger(logger):
|
||||
os.environ['WEXPECT_LOGGER_LEVEL'] = 'DEBUG'
|
||||
try:
|
||||
logger_level = os.environ['WEXPECT_LOGGER_LEVEL']
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user