diff --git a/.travis.yml b/.travis.yml index d345f1d..33b6e93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python python: - 2.7 - - 3.3 - 3.5 before_install: diff --git a/test/test_websocket.py b/test/test_websocket.py index 96fb384..501218d 100644 --- a/test/test_websocket.py +++ b/test/test_websocket.py @@ -4,6 +4,11 @@ import socket import struct +try: + from io import BytesIO +except ImportError: + from StringIO import StringIO as BytesIO + from mock import MagicMock, call, patch from ws4py.framing import Frame, \ @@ -177,6 +182,25 @@ def test_sending_ping(self): ws.ping("hello") m.sendall.assert_called_once_with(tm) + def test_spill_frame(self): + data = b"hello" + buf = BytesIO(data + b"spillover") + + sock = MagicMock() + sock._ssl = object() # for WebSocket._is_secure logic + sock.recv.side_effect = buf.read + sock.pending.side_effect = lambda: buf.tell() < len(buf.getvalue()) + + ws = WebSocket(sock=sock) + ws.stream = MagicMock() + + self.assertTrue(ws._is_secure) + + ws.reading_buffer_size = len(data) + ws.once() + + ws.stream.parser.send.assert_called_once_with(data) + if __name__ == '__main__': suite = unittest.TestSuite()