Commit 4704731f authored by Denis Bilenko's avatar Denis Bilenko

update test__backdoor.py

parent 39e45c74
......@@ -3,21 +3,22 @@ import gevent
from gevent import socket
from gevent import backdoor
class Test(greentest.TestCase):
def test(self):
g = gevent.spawn(backdoor.backdoor_server, socket.tcp_listener(('127.0.0.1', 7891)))
server = backdoor.BackdoorServer.spawn(('127.0.0.1', 7891))
gevent.sleep(0.1)
s = socket.create_connection(('127.0.0.1', 7891))
f = s.makefile()
fileobj = socket.create_connection(('127.0.0.1', 7891)).makefile()
while True:
line = gevent.with_timeout(0.1, f.readline, timeout_value=None)
line = gevent.with_timeout(0.1, fileobj.readline, timeout_value=None)
if line is None:
break
s.sendall('2+2\r\n')
l = f.readline()
assert l.strip() == '4', repr(l)
g.kill(block=True)
fileobj.write('2+2\r\n')
fileobj.flush()
line = fileobj.readline()
assert line.strip() == '4', repr(line)
server.kill(block=True)
if __name__ == '__main__':
......
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