Browse Source

flake8 fixes

pull/319/head
Miguel Grinberg 6 years ago
parent
commit
18fa5286c7
No known key found for this signature in database GPG Key ID: 36848B262DF5F06C
  1. 2
      socketio/packet.py
  2. 14
      tests/asyncio/test_asyncio_server.py
  3. 3
      tests/common/test_server.py

2
socketio/packet.py

@ -14,7 +14,7 @@ class Packet(object):
# the format of the Socket.IO packet is as follows: # the format of the Socket.IO packet is as follows:
# #
# type: 1 byte, values 0-6 # packet type: 1 byte, values 0-6
# num_attachments: ASCII encoded, only if num_attachments != 0 # num_attachments: ASCII encoded, only if num_attachments != 0
# '-': only if num_attachments != 0 # '-': only if num_attachments != 0
# namespace: only if namespace != '/' # namespace: only if namespace != '/'

14
tests/asyncio/test_asyncio_server.py

@ -10,7 +10,7 @@ if six.PY3:
else: else:
import mock import mock
from socketio import asyncio_server, exceptions from socketio import asyncio_server
from socketio import asyncio_namespace from socketio import asyncio_namespace
from socketio import exceptions from socketio import exceptions
from socketio import namespace from socketio import namespace
@ -448,7 +448,8 @@ class TestAsyncServer(unittest.TestCase):
def test_handle_event_binary_ack(self, eio): def test_handle_event_binary_ack(self, eio):
eio.return_value.send = AsyncMock() eio.return_value.send = AsyncMock()
mgr = self._get_mock_manager() mgr = self._get_mock_manager()
s = asyncio_server.AsyncServer(client_manager=mgr, async_handlers=False) s = asyncio_server.AsyncServer(client_manager=mgr,
async_handlers=False)
s.manager.initialize(s) s.manager.initialize(s)
_run(s._handle_eio_message('123', '61-321["my message","a",' _run(s._handle_eio_message('123', '61-321["my message","a",'
'{"_placeholder":true,"num":0}]')) '{"_placeholder":true,"num":0}]'))
@ -479,7 +480,8 @@ class TestAsyncServer(unittest.TestCase):
def test_handle_event_with_ack_tuple(self, eio): def test_handle_event_with_ack_tuple(self, eio):
eio.return_value.send = AsyncMock() eio.return_value.send = AsyncMock()
mgr = self._get_mock_manager() mgr = self._get_mock_manager()
s = asyncio_server.AsyncServer(client_manager=mgr, async_handlers=False) s = asyncio_server.AsyncServer(client_manager=mgr,
async_handlers=False)
handler = mock.MagicMock(return_value=(1, '2', True)) handler = mock.MagicMock(return_value=(1, '2', True))
s.on('my message', handler) s.on('my message', handler)
_run(s._handle_eio_message('123', '21000["my message","a","b","c"]')) _run(s._handle_eio_message('123', '21000["my message","a","b","c"]'))
@ -490,7 +492,8 @@ class TestAsyncServer(unittest.TestCase):
def test_handle_event_with_ack_list(self, eio): def test_handle_event_with_ack_list(self, eio):
eio.return_value.send = AsyncMock() eio.return_value.send = AsyncMock()
mgr = self._get_mock_manager() mgr = self._get_mock_manager()
s = asyncio_server.AsyncServer(client_manager=mgr, async_handlers=False) s = asyncio_server.AsyncServer(client_manager=mgr,
async_handlers=False)
handler = mock.MagicMock(return_value=[1, '2', True]) handler = mock.MagicMock(return_value=[1, '2', True])
s.on('my message', handler) s.on('my message', handler)
_run(s._handle_eio_message('123', '21000["my message","a","b","c"]')) _run(s._handle_eio_message('123', '21000["my message","a","b","c"]'))
@ -501,7 +504,8 @@ class TestAsyncServer(unittest.TestCase):
def test_handle_event_with_ack_binary(self, eio): def test_handle_event_with_ack_binary(self, eio):
eio.return_value.send = AsyncMock() eio.return_value.send = AsyncMock()
mgr = self._get_mock_manager() mgr = self._get_mock_manager()
s = asyncio_server.AsyncServer(client_manager=mgr, async_handlers=False) s = asyncio_server.AsyncServer(client_manager=mgr,
async_handlers=False)
handler = mock.MagicMock(return_value=b'foo') handler = mock.MagicMock(return_value=b'foo')
s.on('my message', handler) s.on('my message', handler)
_run(s._handle_eio_message('123', '21000["my message","foo"]')) _run(s._handle_eio_message('123', '21000["my message","foo"]'))

3
tests/common/test_server.py

@ -424,7 +424,8 @@ class TestServer(unittest.TestCase):
def test_handle_event_with_ack_binary(self, eio): def test_handle_event_with_ack_binary(self, eio):
mgr = mock.MagicMock() mgr = mock.MagicMock()
s = server.Server(client_manager=mgr, binary=True, async_handlers=False) s = server.Server(client_manager=mgr, binary=True,
async_handlers=False)
handler = mock.MagicMock(return_value=b'foo') handler = mock.MagicMock(return_value=b'foo')
s.on('my message', handler) s.on('my message', handler)
s._handle_eio_message('123', '21000["my message","foo"]') s._handle_eio_message('123', '21000["my message","foo"]')

Loading…
Cancel
Save