Skip to content

Commit

Permalink
flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed May 25, 2019
1 parent b46dc0f commit 18fa528
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion socketio/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def event_callback(*args):
six.raise_from(exceptions.TimeoutError(), None)
return callback_args[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):
"""Disconnect from the server.
Expand Down
2 changes: 1 addition & 1 deletion socketio/asyncio_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def event_callback(*args):
six.raise_from(exceptions.TimeoutError(), None)
return callback_args[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):
"""Close a room.
Expand Down
2 changes: 1 addition & 1 deletion socketio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def event_callback(*args):
raise exceptions.TimeoutError()
return callback_args[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):
"""Disconnect from the server."""
Expand Down
2 changes: 1 addition & 1 deletion socketio/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Packet(object):

# 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
# '-': only if num_attachments != 0
# namespace: only if namespace != '/'
Expand Down
2 changes: 1 addition & 1 deletion socketio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def event_callback(*args):
raise exceptions.TimeoutError()
return callback_args[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):
"""Enter a room.
Expand Down
16 changes: 10 additions & 6 deletions tests/asyncio/test_asyncio_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
else:
import mock

from socketio import asyncio_server, exceptions
from socketio import asyncio_server
from socketio import asyncio_namespace
from socketio import exceptions
from socketio import namespace
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_call_without_async_handlers(self, eio):
s = asyncio_server.AsyncServer(client_manager=mgr,
async_handlers=False)
self.assertRaises(RuntimeError, _run,
s.call('foo', sid='123', timeout=12))
s.call('foo', sid='123', timeout=12))

def test_enter_room(self, eio):
mgr = self._get_mock_manager()
Expand Down Expand Up @@ -448,7 +448,8 @@ def test_handle_event_binary(self, eio):
def test_handle_event_binary_ack(self, eio):
eio.return_value.send = AsyncMock()
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)
_run(s._handle_eio_message('123', '61-321["my message","a",'
'{"_placeholder":true,"num":0}]'))
Expand Down Expand Up @@ -479,7 +480,8 @@ def test_handle_event_with_ack_none(self, eio):
def test_handle_event_with_ack_tuple(self, eio):
eio.return_value.send = AsyncMock()
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))
s.on('my message', handler)
_run(s._handle_eio_message('123', '21000["my message","a","b","c"]'))
Expand All @@ -490,7 +492,8 @@ def test_handle_event_with_ack_tuple(self, eio):
def test_handle_event_with_ack_list(self, eio):
eio.return_value.send = AsyncMock()
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])
s.on('my message', handler)
_run(s._handle_eio_message('123', '21000["my message","a","b","c"]'))
Expand All @@ -501,7 +504,8 @@ def test_handle_event_with_ack_list(self, eio):
def test_handle_event_with_ack_binary(self, eio):
eio.return_value.send = AsyncMock()
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')
s.on('my message', handler)
_run(s._handle_eio_message('123', '21000["my message","foo"]'))
Expand Down
3 changes: 2 additions & 1 deletion tests/common/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ def test_handle_event_with_ack_list(self, eio):

def test_handle_event_with_ack_binary(self, eio):
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')
s.on('my message', handler)
s._handle_eio_message('123', '21000["my message","foo"]')
Expand Down

0 comments on commit 18fa528

Please sign in to comment.