MCPcopy Create free account
hub / github.com/sammchardy/python-binance / TestUserSocketFunctionality

Class TestUserSocketFunctionality

tests/test_user_socket_integration.py:102–129  ·  view source on GitHub ↗

Tests verifying user socket functionality works correctly.

Source from the content-addressed store, hash-verified

100
101
102class TestUserSocketFunctionality:
103 """Tests verifying user socket functionality works correctly."""
104
105 @pytest.mark.asyncio
106 async def test_user_socket_recv_timeout(self, clientAsync, socket_manager):
107 """User socket recv() should timeout gracefully when no events."""
108 user_socket = socket_manager.user_socket()
109
110 async with user_socket:
111 # recv() should timeout without errors (no events on quiet account)
112 with pytest.raises(asyncio.TimeoutError):
113 await asyncio.wait_for(user_socket.recv(), timeout=2)
114
115 @pytest.mark.asyncio
116 async def test_user_socket_context_manager(self, clientAsync, socket_manager):
117 """User socket should work as async context manager."""
118 user_socket = socket_manager.user_socket()
119
120 # Should not be connected initially
121 assert user_socket._subscription_id is None
122
123 async with user_socket:
124 # Should be connected inside context
125 assert user_socket._subscription_id is not None
126 assert user_socket._uses_ws_api_subscription is True
127
128 # Subscription ID is cleared after unsubscribe
129 assert user_socket._subscription_id is None
130
131
132class TestNonUserSockets:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…