Skip to content

Commit 6020f43

Browse files
committed
update test to expect errors
1 parent 733754e commit 6020f43

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/test_multiprocessing.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import contextlib
44

55
from redis.connection import Connection, ConnectionPool
6+
from redis.exceptions import ConnectionError
67

78

89
@contextlib.contextmanager
@@ -33,8 +34,9 @@ def target(conn):
3334
assert proc.exitcode is 0
3435

3536
# Check that connection is still alive after fork process has exited.
36-
conn.send_command('ping')
37-
assert conn.read_response() == b'PONG'
37+
with pytest.raises(ConnectionError):
38+
assert conn.send_command('ping') is None
39+
assert conn.read_response() == b'PONG'
3840

3941
def test_close_connection_in_main(self):
4042
conn = Connection()
@@ -54,7 +56,7 @@ def target(conn, ev):
5456
ev.set()
5557

5658
proc.join(3)
57-
assert proc.exitcode is 0
59+
assert proc.exitcode is 1
5860

5961
@pytest.mark.parametrize('max_connections', [1, 2, None])
6062
def test_pool(self, max_connections):
@@ -81,8 +83,9 @@ def target(pool):
8183
# Check that connection is still alive after fork process has exited.
8284
conn = pool.get_connection('ping')
8385
with exit_callback(pool.release, conn):
84-
conn.send_command('ping')
85-
assert conn.read_response() == b'PONG'
86+
with pytest.raises(ConnectionError):
87+
assert conn.send_command('ping') is None
88+
assert conn.read_response() == b'PONG'
8689

8790
@pytest.mark.parametrize('max_connections', [1, 2, None])
8891
def test_close_pool_in_main(self, max_connections):

0 commit comments

Comments
 (0)