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/asyncio_client.py
  2. 2
      socketio/asyncio_server.py
  3. 2
      socketio/client.py
  4. 2
      socketio/packet.py
  5. 2
      socketio/server.py
  6. 16
      tests/asyncio/test_asyncio_server.py
  7. 3
      tests/common/test_server.py

2
socketio/asyncio_client.py

@ -218,7 +218,7 @@ class AsyncClient(client.Client):
six.raise_from(exceptions.TimeoutError(), None) six.raise_from(exceptions.TimeoutError(), None)
return callback_args[0] if len(callback_args[0]) > 1 \ return callback_args[0] if len(callback_args[0]) > 1 \
else callback_args[0][0] if len(callback_args[0]) == 1 \ else callback_args[0][0] if len(callback_args[0]) == 1 \
else None else None
async def disconnect(self): async def disconnect(self):
"""Disconnect from the server. """Disconnect from the server.

2
socketio/asyncio_server.py

@ -200,7 +200,7 @@ class AsyncServer(server.Server):
six.raise_from(exceptions.TimeoutError(), None) six.raise_from(exceptions.TimeoutError(), None)
return callback_args[0] if len(callback_args[0]) > 1 \ return callback_args[0] if len(callback_args[0]) > 1 \
else callback_args[0][0] if len(callback_args[0]) == 1 \ else callback_args[0][0] if len(callback_args[0]) == 1 \
else None else None
async def close_room(self, room, namespace=None): async def close_room(self, room, namespace=None):
"""Close a room. """Close a room.

2
socketio/client.py

@ -314,7 +314,7 @@ class Client(object):
raise exceptions.TimeoutError() raise exceptions.TimeoutError()
return callback_args[0] if len(callback_args[0]) > 1 \ return callback_args[0] if len(callback_args[0]) > 1 \
else callback_args[0][0] if len(callback_args[0]) == 1 \ else callback_args[0][0] if len(callback_args[0]) == 1 \
else None else None
def disconnect(self): def disconnect(self):
"""Disconnect from the server.""" """Disconnect from the server."""

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 != '/'

2
socketio/server.py

@ -321,7 +321,7 @@ class Server(object):
raise exceptions.TimeoutError() raise exceptions.TimeoutError()
return callback_args[0] if len(callback_args[0]) > 1 \ return callback_args[0] if len(callback_args[0]) > 1 \
else callback_args[0][0] if len(callback_args[0]) == 1 \ else callback_args[0][0] if len(callback_args[0]) == 1 \
else None else None
def enter_room(self, sid, room, namespace=None): def enter_room(self, sid, room, namespace=None):
"""Enter a room. """Enter a room.

16
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
@ -134,7 +134,7 @@ class TestAsyncServer(unittest.TestCase):
s = asyncio_server.AsyncServer(client_manager=mgr, s = asyncio_server.AsyncServer(client_manager=mgr,
async_handlers=False) async_handlers=False)
self.assertRaises(RuntimeError, _run, self.assertRaises(RuntimeError, _run,
s.call('foo', sid='123', timeout=12)) s.call('foo', sid='123', timeout=12))
def test_enter_room(self, eio): def test_enter_room(self, eio):
mgr = self._get_mock_manager() mgr = self._get_mock_manager()
@ -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