Skip to content

Commit 2e3d913

Browse files
committed
more debug
1 parent 08ac8cd commit 2e3d913

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

tests/asyncio/test_client.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def create_connection(*args, **kwargs):
156156
) as client:
157157
self.assertTrue(client.create_connection_ran)
158158

159-
@unittest.skip("TODO - skipped to get a passing run")
160159
async def test_reconnect(self):
161160
"""Client reconnects to server."""
162161
iterations = 0
@@ -165,16 +164,24 @@ async def test_reconnect(self):
165164
async def process_request(connection, request):
166165
nonlocal iterations
167166
iterations += 1
167+
connection.logger.critical(f"!!!!! ITERATION {iterations}")
168168
# Retriable errors
169169
if iterations == 1:
170170
await asyncio.sleep(3 * MS)
171171
elif iterations == 2:
172172
connection.transport.close()
173173
elif iterations == 3:
174174
return connection.respond(http.HTTPStatus.SERVICE_UNAVAILABLE, "🚒")
175+
# Successful connection
176+
elif iterations == 4:
177+
pass
178+
elif iterations == 5:
179+
pass
175180
# Fatal error
176181
elif iterations == 6:
177182
return connection.respond(http.HTTPStatus.PAYMENT_REQUIRED, "💸")
183+
else:
184+
self.fail("should stop after 6 iterations")
178185

179186
async with serve(*args, process_request=process_request) as server:
180187
with self.assertRaises(InvalidStatus) as raised:
@@ -190,7 +197,6 @@ async def process_request(connection, request):
190197
self.assertEqual(iterations, 6)
191198
self.assertEqual(successful, 2)
192199

193-
@unittest.skip("TODO - skipped to get a passing run")
194200
async def test_reconnect_with_custom_process_exception(self):
195201
"""Client runs process_exception to tell if errors are retryable or fatal."""
196202
iteration = 0
@@ -200,7 +206,10 @@ def process_request(connection, request):
200206
iteration += 1
201207
if iteration == 1:
202208
return connection.respond(http.HTTPStatus.SERVICE_UNAVAILABLE, "🚒")
203-
return connection.respond(http.HTTPStatus.IM_A_TEAPOT, "🫖")
209+
elif iteration == 2:
210+
return connection.respond(http.HTTPStatus.IM_A_TEAPOT, "🫖")
211+
else:
212+
self.fail("should stop after 2 iterations")
204213

205214
def process_exception(exc):
206215
if isinstance(exc, InvalidStatus):
@@ -224,7 +233,6 @@ def process_exception(exc):
224233
"🫖 💔 ☕️",
225234
)
226235

227-
@unittest.skip("TODO - skipped to get a passing run")
228236
async def test_reconnect_with_custom_process_exception_raising_exception(self):
229237
"""Client supports raising an exception in process_exception."""
230238

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ deps =
2020

2121
[testenv:coverage]
2222
commands =
23-
python -m coverage run --source {envsitepackagesdir}/websockets,tests -m unittest {posargs}
23+
python -u -m coverage run --source {envsitepackagesdir}/websockets,tests -m unittest -v -k test_reconnect {posargs}
2424
python -m coverage report --show-missing --fail-under=100
2525
deps =
2626
coverage
2727
mitmproxy
2828
python-socks
29+
setenv =
30+
WEBSOCKETS_DEBUG=1
2931

3032
[testenv:maxi_cov]
3133
commands =

0 commit comments

Comments
 (0)