An error in Connection.on_connect should disconnect from the server see for details: https://github.com/andymccurdy/redis-py/issues/368
(self)
| 917 | class TestConnection: |
| 918 | @pytest.mark.fixed_client |
| 919 | def test_on_connect_error(self): |
| 920 | """ |
| 921 | An error in Connection.on_connect should disconnect from the server |
| 922 | see for details: https://github.com/andymccurdy/redis-py/issues/368 |
| 923 | """ |
| 924 | # this assumes the Redis server being tested against doesn't have |
| 925 | # 9999 databases ;) |
| 926 | bad_connection = redis.Redis(db=9999) |
| 927 | # an error should be raised on connect |
| 928 | with pytest.raises(redis.RedisError): |
| 929 | bad_connection.info() |
| 930 | pool = bad_connection.connection_pool |
| 931 | assert len(pool._available_connections) == 1 |
| 932 | assert not pool._available_connections[0]._sock |
| 933 | |
| 934 | @pytest.mark.onlynoncluster |
| 935 | @skip_if_server_version_lt("2.8.8") |