diff options
Diffstat (limited to 'tests/socket_test.py')
| -rw-r--r-- | tests/socket_test.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/socket_test.py b/tests/socket_test.py index 60881f7..634e1f0 100644 --- a/tests/socket_test.py +++ b/tests/socket_test.py @@ -1,3 +1,4 @@ +import eventlet from eventlet.green import socket @@ -6,3 +7,25 @@ def test_create_connection_error(): socket.create_connection(('192.0.2.1', 80), timeout=0.1) except (IOError, OSError): pass + + +def test_recv_type(): + # https://github.com/eventlet/eventlet/issues/245 + # socket recv returning multiple data types + # For this test to work, client and server have to be in separate + # processes or OS threads. Just running two greenthreads gives + # false test pass. + threading = eventlet.patcher.original('threading') + addr = [] + + def server(): + sock = eventlet.listen(('127.0.0.1', 0)) + addr[:] = sock.getsockname() + eventlet.sleep(0.2) + + server_thread = threading.Thread(target=server) + server_thread.start() + eventlet.sleep(0.1) + sock = eventlet.connect(tuple(addr)) + s = sock.recv(1) + assert isinstance(s, bytes) |
