diff --git a/tests/async/test_admin.py b/tests/async/test_admin.py index a1cf97c4..62806cbb 100644 --- a/tests/async/test_admin.py +++ b/tests/async/test_admin.py @@ -107,23 +107,23 @@ def test_missing_auth(self): @with_instrumented_server(auth=False) def test_admin_connect_with_no_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin') - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) @with_instrumented_server(auth={'foo': 'bar'}) def test_admin_connect_with_dict_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect( 'http://localhost:8900', namespace='/admin', auth={'foo': 'baz'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect( 'http://localhost:8900', namespace='/admin') @@ -131,52 +131,52 @@ def test_admin_connect_with_dict_auth(self): @with_instrumented_server(auth=[{'foo': 'bar'}, {'u': 'admin', 'p': 'secret'}]) def test_admin_connect_with_list_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'u': 'admin', 'p': 'secret'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'baz'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin') @with_instrumented_server(auth=_custom_auth) def test_admin_connect_with_function_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'baz'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin') @with_instrumented_server(auth=_async_custom_auth) def test_admin_connect_with_async_function_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'baz'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin') @with_instrumented_server() def test_admin_connect_only_admin(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin') sid = admin_client.sid events = self._expect({'config': 1, 'all_sockets': 1, @@ -201,10 +201,10 @@ def test_admin_connect_only_admin(self): @with_instrumented_server() def test_admin_connect_with_others(self): - with socketio.SimpleClient() as client1, \ - socketio.SimpleClient() as client2, \ - socketio.SimpleClient() as client3, \ - socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as client1, \ + socketio.SimpleClient(reconnection=False) as client2, \ + socketio.SimpleClient(reconnection=False) as client3, \ + socketio.SimpleClient(reconnection=False) as admin_client: client1.connect('http://localhost:8900') client1.emit('enter_room', 'room') sid1 = client1.sid @@ -251,7 +251,7 @@ def test_admin_connect_with_others(self): @with_instrumented_server(mode='production', read_only=True) def test_admin_connect_production(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin') events = self._expect({'config': 1, 'server_stats': 2}, admin_client) @@ -272,9 +272,9 @@ def test_admin_connect_production(self): @with_instrumented_server() def test_admin_features(self): - with socketio.SimpleClient() as client1, \ - socketio.SimpleClient() as client2, \ - socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as client1, \ + socketio.SimpleClient(reconnection=False) as client2, \ + socketio.SimpleClient(reconnection=False) as admin_client: client1.connect('http://localhost:8900') client2.connect('http://localhost:8900') admin_client.connect('http://localhost:8900', namespace='/admin') diff --git a/tests/common/test_admin.py b/tests/common/test_admin.py index e7667311..a3847898 100644 --- a/tests/common/test_admin.py +++ b/tests/common/test_admin.py @@ -97,23 +97,23 @@ def test_missing_auth(self): @with_instrumented_server(auth=False) def test_admin_connect_with_no_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin') - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) @with_instrumented_server(auth={'foo': 'bar'}) def test_admin_connect_with_dict_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect( 'http://localhost:8900', namespace='/admin', auth={'foo': 'baz'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect( 'http://localhost:8900', namespace='/admin') @@ -121,38 +121,38 @@ def test_admin_connect_with_dict_auth(self): @with_instrumented_server(auth=[{'foo': 'bar'}, {'u': 'admin', 'p': 'secret'}]) def test_admin_connect_with_list_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'u': 'admin', 'p': 'secret'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'baz'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin') @with_instrumented_server(auth=_custom_auth) def test_admin_connect_with_function_auth(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'bar'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin', auth={'foo': 'baz'}) - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: with pytest.raises(ConnectionError): admin_client.connect('http://localhost:8900', namespace='/admin') @with_instrumented_server() def test_admin_connect_only_admin(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin') sid = admin_client.sid events = self._expect({'config': 1, 'all_sockets': 1, @@ -177,10 +177,10 @@ def test_admin_connect_only_admin(self): @with_instrumented_server() def test_admin_connect_with_others(self): - with socketio.SimpleClient() as client1, \ - socketio.SimpleClient() as client2, \ - socketio.SimpleClient() as client3, \ - socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as client1, \ + socketio.SimpleClient(reconnection=False) as client2, \ + socketio.SimpleClient(reconnection=False) as client3, \ + socketio.SimpleClient(reconnection=False) as admin_client: client1.connect('http://localhost:8900') client1.emit('enter_room', 'room') sid1 = client1.sid @@ -227,7 +227,7 @@ def test_admin_connect_with_others(self): @with_instrumented_server(mode='production', read_only=True) def test_admin_connect_production(self): - with socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as admin_client: admin_client.connect('http://localhost:8900', namespace='/admin') events = self._expect({'config': 1, 'server_stats': 2}, admin_client) @@ -248,9 +248,9 @@ def test_admin_connect_production(self): @with_instrumented_server() def test_admin_features(self): - with socketio.SimpleClient() as client1, \ - socketio.SimpleClient() as client2, \ - socketio.SimpleClient() as admin_client: + with socketio.SimpleClient(reconnection=False) as client1, \ + socketio.SimpleClient(reconnection=False) as client2, \ + socketio.SimpleClient(reconnection=False) as admin_client: client1.connect('http://localhost:8900') client2.connect('http://localhost:8900') admin_client.connect('http://localhost:8900', namespace='/admin') diff --git a/tests/web_server.py b/tests/web_server.py index cb24668e..113d475e 100644 --- a/tests/web_server.py +++ b/tests/web_server.py @@ -47,7 +47,7 @@ def get_environ(self): env['gunicorn.socket'] = self.connection return env - self.httpd = make_server('', port, self._app_wrapper, + self.httpd = make_server('localhost', port, self._app_wrapper, ThreadingWSGIServer, WebSocketRequestHandler) self.thread = threading.Thread(target=self.httpd.serve_forever) self.thread.start()