Browse Source

Ignore catch-all namespace in client connections (Fixes #1351)

pull/1353/head
Miguel Grinberg 10 months ago
parent
commit
469b7c0dd5
Failed to extract signature
  1. 2
      src/socketio/async_client.py
  2. 2
      src/socketio/client.py
  3. 1
      tests/async/test_client.py
  4. 1
      tests/common/test_client.py

2
src/socketio/async_client.py

@ -128,6 +128,8 @@ class AsyncClient(base_client.BaseClient):
if namespaces is None:
namespaces = list(set(self.handlers.keys()).union(
set(self.namespace_handlers.keys())))
if '*' in namespaces:
namespaces.remove('*')
if len(namespaces) == 0:
namespaces = ['/']
elif isinstance(namespaces, str):

2
src/socketio/client.py

@ -126,6 +126,8 @@ class Client(base_client.BaseClient):
if namespaces is None:
namespaces = list(set(self.handlers.keys()).union(
set(self.namespace_handlers.keys())))
if '*' in namespaces:
namespaces.remove('*')
if len(namespaces) == 0:
namespaces = ['/']
elif isinstance(namespaces, str):

1
tests/async/test_client.py

@ -98,6 +98,7 @@ class TestAsyncClient(unittest.TestCase):
c.eio.connect = AsyncMock()
c.on('foo', mock.MagicMock(), namespace='/foo')
c.on('bar', mock.MagicMock(), namespace='/')
c.on('baz', mock.MagicMock(), namespace='*')
_run(
c.connect(
'url',

1
tests/common/test_client.py

@ -236,6 +236,7 @@ class TestClient(unittest.TestCase):
c.eio.connect = mock.MagicMock()
c.on('foo', mock.MagicMock(), namespace='/foo')
c.on('bar', mock.MagicMock(), namespace='/')
c.on('baz', mock.MagicMock(), namespace='*')
c.connect(
'url',
headers='headers',

Loading…
Cancel
Save