3
3
import contextlib
4
4
5
5
from redis .connection import Connection , ConnectionPool
6
+ from redis .exceptions import ConnectionError
6
7
7
8
8
9
@contextlib .contextmanager
@@ -33,8 +34,9 @@ def target(conn):
33
34
assert proc .exitcode is 0
34
35
35
36
# 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'
38
40
39
41
def test_close_connection_in_main (self ):
40
42
conn = Connection ()
@@ -54,7 +56,7 @@ def target(conn, ev):
54
56
ev .set ()
55
57
56
58
proc .join (3 )
57
- assert proc .exitcode is 0
59
+ assert proc .exitcode is 1
58
60
59
61
@pytest .mark .parametrize ('max_connections' , [1 , 2 , None ])
60
62
def test_pool (self , max_connections ):
@@ -81,8 +83,9 @@ def target(pool):
81
83
# Check that connection is still alive after fork process has exited.
82
84
conn = pool .get_connection ('ping' )
83
85
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'
86
89
87
90
@pytest .mark .parametrize ('max_connections' , [1 , 2 , None ])
88
91
def test_close_pool_in_main (self , max_connections ):
0 commit comments