Commit a49eca42 authored by Denis Bilenko's avatar Denis Bilenko

fix test__backdoor.py to work on freebsd

parent 96a6e0e4
......@@ -4,19 +4,25 @@ from gevent import socket
from gevent import backdoor
def read_until(conn, postfix):
read = ''
while not read.endswith(postfix):
result = conn.recv(1)
if not result:
raise AssertionError('Connection ended before %r. Data read:\n%r' % (postfix, read))
read += result
return read
class Test(greentest.TestCase):
def test(self):
server = backdoor.BackdoorServer.spawn(('127.0.0.1', 7891))
gevent.sleep(0.1)
fileobj = socket.create_connection(('127.0.0.1', 7891)).makefile()
while True:
line = gevent.with_timeout(0.1, fileobj.readline, timeout_value=None)
if line is None:
break
fileobj.write('2+2\r\n')
fileobj.flush()
line = fileobj.readline()
gevent.sleep(0)
conn = socket.create_connection(('127.0.0.1', 7891))
read_until(conn, '>>> ')
conn.sendall('2+2\r\n')
line = conn.makefile().readline()
assert line.strip() == '4', repr(line)
server.kill(block=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment