Skip to content

Commit 6bada77

Browse files
committed
Simplify test
1 parent b8867a2 commit 6bada77

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

tests/test_asyncio/test_commands.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,18 +3017,14 @@ async def helper():
30173017
await r.brpop(["nonexist"])
30183018
# if all is well, we can continue. The following should not hang.
30193019
await r.set("status", "down")
3020-
return "done"
30213020

30223021
task = asyncio.create_task(helper())
30233022
await ready.wait()
30243023
await asyncio.sleep(0.01)
30253024
# the task is now sleeping, lets send it an exception
30263025
task.cancel()
3027-
try:
3028-
async with async_timeout.timeout(0.1):
3029-
assert await task == "done"
3030-
except asyncio.TimeoutError:
3031-
task.cancel()
3026+
# If all is well, the task should finish right away, otherwise fail with Timeout
3027+
async with async_timeout.timeout(0.1):
30323028
await task
30333029

30343030

tests/test_commands.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4723,18 +4723,14 @@ def test_interrupted_command(self, r: redis.Redis):
47234723
will leave the socket with un-read response to a previous
47244724
command.
47254725
"""
4726-
print("start")
4727-
4726+
47284727
def helper():
4729-
try:
4728+
with pytest.raises(BaseException):
47304729
# blocking pop
47314730
with patch.object(
47324731
socket.socket, "recv_into", side_effect=CancelledError
47334732
) as mock_recv:
47344733
r.brpop(["nonexist"])
4735-
except CancelledError:
4736-
print("canc")
4737-
pass # we got some BaseException.
47384734
# if all is well, we can continue.
47394735
r.set("status", "down") # should not hang
47404736

0 commit comments

Comments
 (0)