diff options
author | Alexey Popravka <a.popravka@smartweb.com.ua> | 2019-01-03 13:13:52 +0200 |
---|---|---|
committer | Alexey Popravka <a.popravka@smartweb.com.ua> | 2019-01-03 13:13:52 +0200 |
commit | 6020f43264209b2430a01fc3098d74bb142942a7 (patch) | |
tree | 5d1c62bd327d0c3b8945bcdd6ef032a41baeb97c | |
parent | 733754e13b52bce6687d5a88c1075c963d034722 (diff) | |
download | redis-py-6020f43264209b2430a01fc3098d74bb142942a7.tar.gz |
update test to expect errors
-rw-r--r-- | tests/test_multiprocessing.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/test_multiprocessing.py b/tests/test_multiprocessing.py index 8af1459..dae35bc 100644 --- a/tests/test_multiprocessing.py +++ b/tests/test_multiprocessing.py @@ -3,6 +3,7 @@ import multiprocessing import contextlib from redis.connection import Connection, ConnectionPool +from redis.exceptions import ConnectionError @contextlib.contextmanager @@ -33,8 +34,9 @@ class TestMultiprocessing(object): assert proc.exitcode is 0 # Check that connection is still alive after fork process has exited. - conn.send_command('ping') - assert conn.read_response() == b'PONG' + with pytest.raises(ConnectionError): + assert conn.send_command('ping') is None + assert conn.read_response() == b'PONG' def test_close_connection_in_main(self): conn = Connection() @@ -54,7 +56,7 @@ class TestMultiprocessing(object): ev.set() proc.join(3) - assert proc.exitcode is 0 + assert proc.exitcode is 1 @pytest.mark.parametrize('max_connections', [1, 2, None]) def test_pool(self, max_connections): @@ -81,8 +83,9 @@ class TestMultiprocessing(object): # Check that connection is still alive after fork process has exited. conn = pool.get_connection('ping') with exit_callback(pool.release, conn): - conn.send_command('ping') - assert conn.read_response() == b'PONG' + with pytest.raises(ConnectionError): + assert conn.send_command('ping') is None + assert conn.read_response() == b'PONG' @pytest.mark.parametrize('max_connections', [1, 2, None]) def test_close_pool_in_main(self, max_connections): |