Browse Source

Removed dependency on unittest.TestCase base class

pull/1409/head
Miguel Grinberg 4 months ago
parent
commit
abf336e108
Failed to extract signature
  1. 40
      tests/async/test_admin.py
  2. 3
      tests/async/test_client.py
  3. 5
      tests/async/test_manager.py
  4. 5
      tests/async/test_namespace.py
  5. 5
      tests/async/test_pubsub_manager.py
  6. 5
      tests/async/test_server.py
  7. 3
      tests/async/test_simple_client.py
  8. 38
      tests/common/test_admin.py
  9. 3
      tests/common/test_client.py
  10. 5
      tests/common/test_manager.py
  11. 3
      tests/common/test_middleware.py
  12. 4
      tests/common/test_msgpack_packet.py
  13. 3
      tests/common/test_namespace.py
  14. 4
      tests/common/test_packet.py
  15. 5
      tests/common/test_pubsub_manager.py
  16. 5
      tests/common/test_server.py
  17. 3
      tests/common/test_simple_client.py

40
tests/async/test_admin.py

@ -2,7 +2,6 @@ from functools import wraps
import threading import threading
import time import time
from unittest import mock from unittest import mock
import unittest
import pytest import pytest
try: try:
from engineio.async_socket import AsyncSocket as EngineIOSocket from engineio.async_socket import AsyncSocket as EngineIOSocket
@ -38,13 +37,13 @@ def with_instrumented_server(auth=False, **ikwargs):
pass pass
async def shutdown(): async def shutdown():
await instrumented_server.shutdown() await self.isvr.shutdown()
await sio.shutdown() await sio.shutdown()
if 'server_stats_interval' not in ikwargs: if 'server_stats_interval' not in ikwargs:
ikwargs['server_stats_interval'] = 0.25 ikwargs['server_stats_interval'] = 0.25
instrumented_server = sio.instrument(auth=auth, **ikwargs) self.isvr = sio.instrument(auth=auth, **ikwargs)
server = SocketIOWebServer(sio, on_shutdown=shutdown) server = SocketIOWebServer(sio, on_shutdown=shutdown)
server.start() server.start()
@ -56,10 +55,11 @@ def with_instrumented_server(auth=False, **ikwargs):
EngineIOSocket.schedule_ping = mock.MagicMock() EngineIOSocket.schedule_ping = mock.MagicMock()
try: try:
ret = f(self, instrumented_server, *args, **kwargs) ret = f(self, *args, **kwargs)
finally: finally:
server.stop() server.stop()
instrumented_server.uninstrument() self.isvr.uninstrument()
self.isvr = None
EngineIOSocket.schedule_ping = original_schedule_ping EngineIOSocket.schedule_ping = original_schedule_ping
@ -80,12 +80,12 @@ async def _async_custom_auth(auth):
return auth == {'foo': 'bar'} return auth == {'foo': 'bar'}
class TestAsyncAdmin(unittest.TestCase): class TestAsyncAdmin:
def setUp(self): def setup_method(self):
print('threads at start:', threading.enumerate()) print('threads at start:', threading.enumerate())
self.thread_count = threading.active_count() self.thread_count = threading.active_count()
def tearDown(self): def teardown_method(self):
print('threads at end:', threading.enumerate()) print('threads at end:', threading.enumerate())
assert self.thread_count == threading.active_count() assert self.thread_count == threading.active_count()
@ -107,7 +107,7 @@ class TestAsyncAdmin(unittest.TestCase):
sio.instrument() sio.instrument()
@with_instrumented_server(auth=False) @with_instrumented_server(auth=False)
def test_admin_connect_with_no_auth(self, isvr): def test_admin_connect_with_no_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin') admin_client.connect('http://localhost:8900', namespace='/admin')
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
@ -115,7 +115,7 @@ class TestAsyncAdmin(unittest.TestCase):
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@with_instrumented_server(auth={'foo': 'bar'}) @with_instrumented_server(auth={'foo': 'bar'})
def test_admin_connect_with_dict_auth(self, isvr): def test_admin_connect_with_dict_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin', admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@ -131,7 +131,7 @@ class TestAsyncAdmin(unittest.TestCase):
@with_instrumented_server(auth=[{'foo': 'bar'}, @with_instrumented_server(auth=[{'foo': 'bar'},
{'u': 'admin', 'p': 'secret'}]) {'u': 'admin', 'p': 'secret'}])
def test_admin_connect_with_list_auth(self, isvr): def test_admin_connect_with_list_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin', admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@ -148,7 +148,7 @@ class TestAsyncAdmin(unittest.TestCase):
namespace='/admin') namespace='/admin')
@with_instrumented_server(auth=_custom_auth) @with_instrumented_server(auth=_custom_auth)
def test_admin_connect_with_function_auth(self, isvr): def test_admin_connect_with_function_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin', admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@ -162,7 +162,7 @@ class TestAsyncAdmin(unittest.TestCase):
namespace='/admin') namespace='/admin')
@with_instrumented_server(auth=_async_custom_auth) @with_instrumented_server(auth=_async_custom_auth)
def test_admin_connect_with_async_function_auth(self, isvr): def test_admin_connect_with_async_function_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin', admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@ -176,7 +176,7 @@ class TestAsyncAdmin(unittest.TestCase):
namespace='/admin') namespace='/admin')
@with_instrumented_server() @with_instrumented_server()
def test_admin_connect_only_admin(self, isvr): def test_admin_connect_only_admin(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin') admin_client.connect('http://localhost:8900', namespace='/admin')
sid = admin_client.sid sid = admin_client.sid
@ -201,7 +201,7 @@ class TestAsyncAdmin(unittest.TestCase):
events['server_stats']['namespaces'] events['server_stats']['namespaces']
@with_instrumented_server() @with_instrumented_server()
def test_admin_connect_with_others(self, isvr): def test_admin_connect_with_others(self):
with socketio.SimpleClient() as client1, \ with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \ socketio.SimpleClient() as client2, \
socketio.SimpleClient() as client3, \ socketio.SimpleClient() as client3, \
@ -210,12 +210,12 @@ class TestAsyncAdmin(unittest.TestCase):
client1.emit('enter_room', 'room') client1.emit('enter_room', 'room')
sid1 = client1.sid sid1 = client1.sid
saved_check_for_upgrade = isvr._check_for_upgrade saved_check_for_upgrade = self.isvr._check_for_upgrade
isvr._check_for_upgrade = AsyncMock() self.isvr._check_for_upgrade = AsyncMock()
client2.connect('http://localhost:8900', namespace='/foo', client2.connect('http://localhost:8900', namespace='/foo',
transports=['polling']) transports=['polling'])
sid2 = client2.sid sid2 = client2.sid
isvr._check_for_upgrade = saved_check_for_upgrade self.isvr._check_for_upgrade = saved_check_for_upgrade
client3.connect('http://localhost:8900', namespace='/admin') client3.connect('http://localhost:8900', namespace='/admin')
sid3 = client3.sid sid3 = client3.sid
@ -251,7 +251,7 @@ class TestAsyncAdmin(unittest.TestCase):
assert socket['rooms'] == [sid3] assert socket['rooms'] == [sid3]
@with_instrumented_server(mode='production', read_only=True) @with_instrumented_server(mode='production', read_only=True)
def test_admin_connect_production(self, isvr): def test_admin_connect_production(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin') admin_client.connect('http://localhost:8900', namespace='/admin')
events = self._expect({'config': 1, 'server_stats': 2}, events = self._expect({'config': 1, 'server_stats': 2},
@ -272,7 +272,7 @@ class TestAsyncAdmin(unittest.TestCase):
events['server_stats']['namespaces'] events['server_stats']['namespaces']
@with_instrumented_server() @with_instrumented_server()
def test_admin_features(self, isvr): def test_admin_features(self):
with socketio.SimpleClient() as client1, \ with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \ socketio.SimpleClient() as client2, \
socketio.SimpleClient() as admin_client: socketio.SimpleClient() as admin_client:

3
tests/async/test_client.py

@ -1,5 +1,4 @@
import asyncio import asyncio
import unittest
from unittest import mock from unittest import mock
import pytest import pytest
@ -12,7 +11,7 @@ from socketio import packet
from .helpers import AsyncMock, _run from .helpers import AsyncMock, _run
class TestAsyncClient(unittest.TestCase): class TestAsyncClient:
def test_is_asyncio_based(self): def test_is_asyncio_based(self):
c = async_client.AsyncClient() c = async_client.AsyncClient()
assert c.is_asyncio_based() assert c.is_asyncio_based()

5
tests/async/test_manager.py

@ -1,4 +1,3 @@
import unittest
from unittest import mock from unittest import mock
from socketio import async_manager from socketio import async_manager
@ -6,8 +5,8 @@ from socketio import packet
from .helpers import AsyncMock, _run from .helpers import AsyncMock, _run
class TestAsyncManager(unittest.TestCase): class TestAsyncManager:
def setUp(self): def setup_method(self):
id = 0 id = 0
def generate_id(): def generate_id():

5
tests/async/test_namespace.py

@ -1,13 +1,10 @@
import sys
import unittest
from unittest import mock from unittest import mock
from socketio import async_namespace from socketio import async_namespace
from .helpers import AsyncMock, _run from .helpers import AsyncMock, _run
@unittest.skipIf(sys.version_info < (3, 5), 'only for Python 3.5+') class TestAsyncNamespace:
class TestAsyncNamespace(unittest.TestCase):
def test_connect_event(self): def test_connect_event(self):
result = {} result = {}

5
tests/async/test_pubsub_manager.py

@ -1,6 +1,5 @@
import asyncio import asyncio
import functools import functools
import unittest
from unittest import mock from unittest import mock
import pytest import pytest
@ -11,8 +10,8 @@ from socketio import packet
from .helpers import AsyncMock, _run from .helpers import AsyncMock, _run
class TestAsyncPubSubManager(unittest.TestCase): class TestAsyncPubSubManager:
def setUp(self): def setup_method(self):
id = 0 id = 0
def generate_id(): def generate_id():

5
tests/async/test_server.py

@ -1,6 +1,5 @@
import asyncio import asyncio
import logging import logging
import unittest
from unittest import mock from unittest import mock
from engineio import json from engineio import json
@ -18,8 +17,8 @@ from .helpers import AsyncMock, _run
@mock.patch('socketio.server.engineio.AsyncServer', **{ @mock.patch('socketio.server.engineio.AsyncServer', **{
'return_value.generate_id.side_effect': [str(i) for i in range(1, 10)], 'return_value.generate_id.side_effect': [str(i) for i in range(1, 10)],
'return_value.send_packet': AsyncMock()}) 'return_value.send_packet': AsyncMock()})
class TestAsyncServer(unittest.TestCase): class TestAsyncServer:
def tearDown(self): def teardown_method(self):
# restore JSON encoder, in case a test changed it # restore JSON encoder, in case a test changed it
packet.Packet.json = json packet.Packet.json = json

3
tests/async/test_simple_client.py

@ -1,5 +1,4 @@
import asyncio import asyncio
import unittest
from unittest import mock from unittest import mock
import pytest import pytest
@ -8,7 +7,7 @@ from socketio.exceptions import SocketIOError, TimeoutError, DisconnectedError
from .helpers import AsyncMock, _run from .helpers import AsyncMock, _run
class TestAsyncAsyncSimpleClient(unittest.TestCase): class TestAsyncAsyncSimpleClient:
def test_constructor(self): def test_constructor(self):
client = AsyncSimpleClient(1, '2', a='3', b=4) client = AsyncSimpleClient(1, '2', a='3', b=4)
assert client.client_args == (1, '2') assert client.client_args == (1, '2')

38
tests/common/test_admin.py

@ -2,7 +2,6 @@ from functools import wraps
import threading import threading
import time import time
from unittest import mock from unittest import mock
import unittest
import pytest import pytest
from engineio.socket import Socket as EngineIOSocket from engineio.socket import Socket as EngineIOSocket
import socketio import socketio
@ -36,7 +35,7 @@ def with_instrumented_server(auth=False, **ikwargs):
if 'server_stats_interval' not in ikwargs: if 'server_stats_interval' not in ikwargs:
ikwargs['server_stats_interval'] = 0.25 ikwargs['server_stats_interval'] = 0.25
instrumented_server = sio.instrument(auth=auth, **ikwargs) self.isvr = sio.instrument(auth=auth, **ikwargs)
server = SocketIOWebServer(sio) server = SocketIOWebServer(sio)
server.start() server.start()
@ -48,11 +47,12 @@ def with_instrumented_server(auth=False, **ikwargs):
EngineIOSocket.schedule_ping = mock.MagicMock() EngineIOSocket.schedule_ping = mock.MagicMock()
try: try:
ret = f(self, instrumented_server, *args, **kwargs) ret = f(self, *args, **kwargs)
finally: finally:
server.stop() server.stop()
instrumented_server.shutdown() self.isvr.shutdown()
instrumented_server.uninstrument() self.isvr.uninstrument()
self.isvr = None
EngineIOSocket.schedule_ping = original_schedule_ping EngineIOSocket.schedule_ping = original_schedule_ping
@ -69,12 +69,12 @@ def _custom_auth(auth):
return auth == {'foo': 'bar'} return auth == {'foo': 'bar'}
class TestAdmin(unittest.TestCase): class TestAdmin:
def setUp(self): def setup_method(self):
print('threads at start:', threading.enumerate()) print('threads at start:', threading.enumerate())
self.thread_count = threading.active_count() self.thread_count = threading.active_count()
def tearDown(self): def teardown_method(self):
print('threads at end:', threading.enumerate()) print('threads at end:', threading.enumerate())
assert self.thread_count == threading.active_count() assert self.thread_count == threading.active_count()
@ -96,7 +96,7 @@ class TestAdmin(unittest.TestCase):
sio.instrument() sio.instrument()
@with_instrumented_server(auth=False) @with_instrumented_server(auth=False)
def test_admin_connect_with_no_auth(self, isvr): def test_admin_connect_with_no_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin') admin_client.connect('http://localhost:8900', namespace='/admin')
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
@ -104,7 +104,7 @@ class TestAdmin(unittest.TestCase):
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@with_instrumented_server(auth={'foo': 'bar'}) @with_instrumented_server(auth={'foo': 'bar'})
def test_admin_connect_with_dict_auth(self, isvr): def test_admin_connect_with_dict_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin', admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@ -120,7 +120,7 @@ class TestAdmin(unittest.TestCase):
@with_instrumented_server(auth=[{'foo': 'bar'}, @with_instrumented_server(auth=[{'foo': 'bar'},
{'u': 'admin', 'p': 'secret'}]) {'u': 'admin', 'p': 'secret'}])
def test_admin_connect_with_list_auth(self, isvr): def test_admin_connect_with_list_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin', admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@ -137,7 +137,7 @@ class TestAdmin(unittest.TestCase):
namespace='/admin') namespace='/admin')
@with_instrumented_server(auth=_custom_auth) @with_instrumented_server(auth=_custom_auth)
def test_admin_connect_with_function_auth(self, isvr): def test_admin_connect_with_function_auth(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin', admin_client.connect('http://localhost:8900', namespace='/admin',
auth={'foo': 'bar'}) auth={'foo': 'bar'})
@ -151,7 +151,7 @@ class TestAdmin(unittest.TestCase):
namespace='/admin') namespace='/admin')
@with_instrumented_server() @with_instrumented_server()
def test_admin_connect_only_admin(self, isvr): def test_admin_connect_only_admin(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin') admin_client.connect('http://localhost:8900', namespace='/admin')
sid = admin_client.sid sid = admin_client.sid
@ -176,7 +176,7 @@ class TestAdmin(unittest.TestCase):
events['server_stats']['namespaces'] events['server_stats']['namespaces']
@with_instrumented_server() @with_instrumented_server()
def test_admin_connect_with_others(self, isvr): def test_admin_connect_with_others(self):
with socketio.SimpleClient() as client1, \ with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \ socketio.SimpleClient() as client2, \
socketio.SimpleClient() as client3, \ socketio.SimpleClient() as client3, \
@ -185,12 +185,12 @@ class TestAdmin(unittest.TestCase):
client1.emit('enter_room', 'room') client1.emit('enter_room', 'room')
sid1 = client1.sid sid1 = client1.sid
saved_check_for_upgrade = isvr._check_for_upgrade saved_check_for_upgrade = self.isvr._check_for_upgrade
isvr._check_for_upgrade = mock.MagicMock() self.isvr._check_for_upgrade = mock.MagicMock()
client2.connect('http://localhost:8900', namespace='/foo', client2.connect('http://localhost:8900', namespace='/foo',
transports=['polling']) transports=['polling'])
sid2 = client2.sid sid2 = client2.sid
isvr._check_for_upgrade = saved_check_for_upgrade self.isvr._check_for_upgrade = saved_check_for_upgrade
client3.connect('http://localhost:8900', namespace='/admin') client3.connect('http://localhost:8900', namespace='/admin')
sid3 = client3.sid sid3 = client3.sid
@ -226,7 +226,7 @@ class TestAdmin(unittest.TestCase):
assert socket['rooms'] == [sid3] assert socket['rooms'] == [sid3]
@with_instrumented_server(mode='production', read_only=True) @with_instrumented_server(mode='production', read_only=True)
def test_admin_connect_production(self, isvr): def test_admin_connect_production(self):
with socketio.SimpleClient() as admin_client: with socketio.SimpleClient() as admin_client:
admin_client.connect('http://localhost:8900', namespace='/admin') admin_client.connect('http://localhost:8900', namespace='/admin')
events = self._expect({'config': 1, 'server_stats': 2}, events = self._expect({'config': 1, 'server_stats': 2},
@ -247,7 +247,7 @@ class TestAdmin(unittest.TestCase):
events['server_stats']['namespaces'] events['server_stats']['namespaces']
@with_instrumented_server() @with_instrumented_server()
def test_admin_features(self, isvr): def test_admin_features(self):
with socketio.SimpleClient() as client1, \ with socketio.SimpleClient() as client1, \
socketio.SimpleClient() as client2, \ socketio.SimpleClient() as client2, \
socketio.SimpleClient() as admin_client: socketio.SimpleClient() as admin_client:

3
tests/common/test_client.py

@ -1,6 +1,5 @@
import logging import logging
import time import time
import unittest
from unittest import mock from unittest import mock
from engineio import exceptions as engineio_exceptions from engineio import exceptions as engineio_exceptions
@ -16,7 +15,7 @@ from socketio import namespace
from socketio import packet from socketio import packet
class TestClient(unittest.TestCase): class TestClient:
def test_is_asyncio_based(self): def test_is_asyncio_based(self):
c = client.Client() c = client.Client()
assert not c.is_asyncio_based() assert not c.is_asyncio_based()

5
tests/common/test_manager.py

@ -1,4 +1,3 @@
import unittest
from unittest import mock from unittest import mock
import pytest import pytest
@ -7,8 +6,8 @@ from socketio import manager
from socketio import packet from socketio import packet
class TestBaseManager(unittest.TestCase): class TestBaseManager:
def setUp(self): def setup_method(self):
id = 0 id = 0
def generate_id(): def generate_id():

3
tests/common/test_middleware.py

@ -1,10 +1,9 @@
import unittest
from unittest import mock from unittest import mock
from socketio import middleware from socketio import middleware
class TestMiddleware(unittest.TestCase): class TestMiddleware:
def test_wsgi_routing(self): def test_wsgi_routing(self):
mock_wsgi_app = mock.MagicMock() mock_wsgi_app = mock.MagicMock()
mock_sio_app = 'foo' mock_sio_app = 'foo'

4
tests/common/test_msgpack_packet.py

@ -1,10 +1,8 @@
import unittest
from socketio import msgpack_packet from socketio import msgpack_packet
from socketio import packet from socketio import packet
class TestMsgPackPacket(unittest.TestCase): class TestMsgPackPacket:
def test_encode_decode(self): def test_encode_decode(self):
p = msgpack_packet.MsgPackPacket( p = msgpack_packet.MsgPackPacket(
packet.CONNECT, data={'auth': {'token': '123'}}, namespace='/foo') packet.CONNECT, data={'auth': {'token': '123'}}, namespace='/foo')

3
tests/common/test_namespace.py

@ -1,10 +1,9 @@
import unittest
from unittest import mock from unittest import mock
from socketio import namespace from socketio import namespace
class TestNamespace(unittest.TestCase): class TestNamespace:
def test_connect_event(self): def test_connect_event(self):
result = {} result = {}

4
tests/common/test_packet.py

@ -1,11 +1,9 @@
import unittest
import pytest import pytest
from socketio import packet from socketio import packet
class TestPacket(unittest.TestCase): class TestPacket:
def test_encode_default_packet(self): def test_encode_default_packet(self):
pkt = packet.Packet() pkt = packet.Packet()
assert pkt.packet_type == packet.EVENT assert pkt.packet_type == packet.EVENT

5
tests/common/test_pubsub_manager.py

@ -1,6 +1,5 @@
import functools import functools
import logging import logging
import unittest
from unittest import mock from unittest import mock
import pytest import pytest
@ -10,8 +9,8 @@ from socketio import pubsub_manager
from socketio import packet from socketio import packet
class TestPubSubManager(unittest.TestCase): class TestPubSubManager:
def setUp(self): def setup_method(self):
id = 0 id = 0
def generate_id(): def generate_id():

5
tests/common/test_server.py

@ -1,5 +1,4 @@
import logging import logging
import unittest
from unittest import mock from unittest import mock
from engineio import json from engineio import json
@ -15,8 +14,8 @@ from socketio import server
@mock.patch('socketio.server.engineio.Server', **{ @mock.patch('socketio.server.engineio.Server', **{
'return_value.generate_id.side_effect': [str(i) for i in range(1, 10)]}) 'return_value.generate_id.side_effect': [str(i) for i in range(1, 10)]})
class TestServer(unittest.TestCase): class TestServer:
def tearDown(self): def teardown_method(self):
# restore JSON encoder, in case a test changed it # restore JSON encoder, in case a test changed it
packet.Packet.json = json packet.Packet.json = json

3
tests/common/test_simple_client.py

@ -1,11 +1,10 @@
import unittest
from unittest import mock from unittest import mock
import pytest import pytest
from socketio import SimpleClient from socketio import SimpleClient
from socketio.exceptions import SocketIOError, TimeoutError, DisconnectedError from socketio.exceptions import SocketIOError, TimeoutError, DisconnectedError
class TestSimpleClient(unittest.TestCase): class TestSimpleClient:
def test_constructor(self): def test_constructor(self):
client = SimpleClient(1, '2', a='3', b=4) client = SimpleClient(1, '2', a='3', b=4)
assert client.client_args == (1, '2') assert client.client_args == (1, '2')

Loading…
Cancel
Save