Restores compatibility with fakeredis (#1324)

main
Selwin Ong 4 years ago committed by GitHub
parent f0afcd3cb3
commit 6028a63607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,6 +18,8 @@ import sys
from collections import Iterable
from distutils.version import StrictVersion
from redis.exceptions import ResponseError
from .compat import as_text, is_python_version, string_types
from .exceptions import TimeoutFormatError
@ -251,8 +253,11 @@ def parse_timeout(timeout):
def get_version(connection):
"""
Return StrictVersion of Redis server version.
Returns StrictVersion of Redis server version.
This function also correctly handles 4 digit redis server versions.
"""
version_string = connection.info("server")["redis_version"]
return StrictVersion('.'.join(version_string.split('.')[:3]))
try:
version_string = connection.info("server")["redis_version"]
except ResponseError: # fakeredis doesn't implement Redis' INFO command
version_string = "5.0.9"
return StrictVersion('.'.join(version_string.split('.')[:3]))

Loading…
Cancel
Save