diff --git a/fakeredis/_basefakesocket.py b/fakeredis/_basefakesocket.py index 76370d9..5dbb050 100644 --- a/fakeredis/_basefakesocket.py +++ b/fakeredis/_basefakesocket.py @@ -4,7 +4,6 @@ import weakref import redis -import six from . import _msgs as msgs from ._commands import ( @@ -190,7 +189,9 @@ def _blocking(self, timeout, func): return ret def _name_to_func(self, name): - name = six.ensure_str(name, encoding='utf-8', errors='replace') + name = (name.decode(encoding='utf-8', errors='replace') + if isinstance(name, bytes) + else str(name).encode(encoding='utf-8', errors='replace')) func_name = name.lower() func = getattr(self, func_name, None) if name.startswith('_') or not func or not hasattr(func, '_fakeredis_sig'): diff --git a/fakeredis/_server.py b/fakeredis/_server.py index 12e245e..b493799 100644 --- a/fakeredis/_server.py +++ b/fakeredis/_server.py @@ -127,7 +127,8 @@ def __init__(self, *args, server=None, connected=True, version=7, **kwargs): 'connection_class': FakeConnection, 'server': server } - conn_pool_args = [ + conn_pool_args = { + 'host', 'db', # Ignoring because AUTH is not implemented # 'username', @@ -139,8 +140,8 @@ def __init__(self, *args, server=None, connected=True, version=7, **kwargs): 'retry_on_timeout', 'max_connections', 'health_check_interval', - 'client_name' - ] + 'client_name', + } for arg in conn_pool_args: if arg in kwds: kwargs[arg] = kwds[arg] diff --git a/poetry.lock b/poetry.lock index d6316d2..0b0eb10 100644 --- a/poetry.lock +++ b/poetry.lock @@ -56,7 +56,7 @@ dev = ["build (==0.8.0)", "flake8 (==4.0.1)", "hashin (==0.17.0)", "pip-tools (= [[package]] name = "certifi" -version = "2022.6.15" +version = "2022.9.24" description = "Python package for providing Mozilla's CA Bundle." category = "dev" optional = false @@ -119,7 +119,7 @@ toml = ["tomli"] [[package]] name = "cryptography" -version = "37.0.4" +version = "38.0.1" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." category = "dev" optional = false @@ -132,7 +132,7 @@ cffi = ">=1.12" docs = ["sphinx (>=1.6.5,!=1.8.0,!=3.1.0,!=3.1.1)", "sphinx-rtd-theme"] docstest = ["pyenchant (>=1.6.11)", "twine (>=1.12.0)", "sphinxcontrib-spelling (>=4.0.1)"] pep8test = ["black", "flake8", "flake8-import-order", "pep8-naming"] -sdist = ["setuptools_rust (>=0.11.4)"] +sdist = ["setuptools-rust (>=0.11.4)"] ssh = ["bcrypt (>=3.1.5)"] test = ["pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"] @@ -205,7 +205,7 @@ pyflakes = ">=2.5.0,<2.6.0" [[package]] name = "hypothesis" -version = "6.54.4" +version = "6.54.6" description = "A library for property-based testing" category = "dev" optional = false @@ -217,7 +217,7 @@ exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} sortedcontainers = ">=2.1.0,<3.0.0" [package.extras] -all = ["black (>=19.10b0)", "click (>=7.0)", "django (>=3.2)", "dpcontracts (>=0.4)", "lark-parser (>=0.6.5)", "libcst (>=0.3.16)", "numpy (>=1.9.0)", "pandas (>=1.0)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "importlib-metadata (>=3.6)", "backports.zoneinfo (>=0.2.1)", "tzdata (>=2022.1)"] +all = ["black (>=19.10b0)", "click (>=7.0)", "django (>=3.2)", "dpcontracts (>=0.4)", "lark-parser (>=0.6.5)", "libcst (>=0.3.16)", "numpy (>=1.9.0)", "pandas (>=1.0)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "importlib-metadata (>=3.6)", "backports.zoneinfo (>=0.2.1)", "tzdata (>=2022.2)"] cli = ["click (>=7.0)", "black (>=19.10b0)", "rich (>=9.0.0)"] codemods = ["libcst (>=0.3.16)"] dateutil = ["python-dateutil (>=1.4)"] @@ -230,11 +230,11 @@ pandas = ["pandas (>=1.0)"] pytest = ["pytest (>=4.6)"] pytz = ["pytz (>=2014.1)"] redis = ["redis (>=3.0.0)"] -zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2022.1)"] +zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2022.2)"] [[package]] name = "idna" -version = "3.3" +version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" category = "dev" optional = false @@ -274,7 +274,7 @@ python-versions = "*" [[package]] name = "jaraco.classes" -version = "3.2.2" +version = "3.2.3" description = "Utility functions for Python class constructs" category = "dev" optional = false @@ -284,8 +284,8 @@ python-versions = ">=3.7" more-itertools = "*" [package.extras] -docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "jaraco.tidelift (>=1.4)"] -testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"] +docs = ["sphinx (>=3.5)", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "jaraco.tidelift (>=1.4)"] +testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "flake8 (<5)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"] [[package]] name = "jeepney" @@ -301,7 +301,7 @@ test = ["async-timeout", "trio", "testpath", "pytest-asyncio (>=0.17)", "pytest- [[package]] name = "keyring" -version = "23.9.0" +version = "23.9.3" description = "Store and access your passwords safely." category = "dev" optional = false @@ -520,7 +520,7 @@ python-versions = "*" [[package]] name = "readme-renderer" -version = "37.1" +version = "37.2" description = "readme_renderer is a library for rendering \"readme\" descriptions for Warehouse" category = "dev" optional = false @@ -625,7 +625,7 @@ jeepney = ">=0.6" name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" @@ -637,14 +637,6 @@ category = "main" optional = false python-versions = "*" -[[package]] -name = "toml" -version = "0.10.2" -description = "Python Library for Tom's Obvious, Minimal Language" -category = "dev" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" - [[package]] name = "tomli" version = "2.0.1" @@ -655,7 +647,7 @@ python-versions = ">=3.7" [[package]] name = "tox" -version = "3.25.1" +version = "3.26.0" description = "tox is a generic virtualenv management and test command line tool" category = "dev" optional = false @@ -669,7 +661,7 @@ packaging = ">=14" pluggy = ">=0.12.0" py = ">=1.4.17" six = ">=1.14.0" -toml = ">=0.9.4" +tomli = {version = ">=2.0.1", markers = "python_version >= \"3.7\" and python_version < \"3.11\""} virtualenv = ">=16.0.0,<20.0.0 || >20.0.0,<20.0.1 || >20.0.1,<20.0.2 || >20.0.2,<20.0.3 || >20.0.3,<20.0.4 || >20.0.4,<20.0.5 || >20.0.5,<20.0.6 || >20.0.6,<20.0.7 || >20.0.7" [package.extras] @@ -769,7 +761,7 @@ lua = ["lupa"] [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "397fb04cb476c4abb56ea30d8aa4d641c95afcb3241ff4aadbf6ac34b8a9339e" +content-hash = "ec00a9373af1095b25586a0865eb86d2b3bacb521f6f8f4f900f359ea03f2b73" [metadata.files] aioredis = [] @@ -824,7 +816,6 @@ rich = [] secretstorage = [] six = [] sortedcontainers = [] -toml = [] tomli = [] tox = [] twine = [] diff --git a/pyproject.toml b/pyproject.toml index bad2825..3fc522c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,8 @@ readme = "README.md" keywords = ["redis", "rq", "django-rq", "rq-scheduler"] authors = [ "James Saryerwinnie ", - "Bruce Merry " + "Bruce Merry ", + "Daniel Moran " ] maintainers = [ "Daniel Moran " @@ -39,7 +40,6 @@ repository = "https://github.com/cunla/fakeredis-py" [tool.poetry.dependencies] python = "^3.7" redis = "<4.4" -six = "^1.16.0" sortedcontainers = "^2.4.0" lupa = { version = "^1.13", optional = true } aioredis = { version = "^2.0.1", optional = true } diff --git a/test/test_init_args.py b/test/test_init_args.py index b77eb24..1d79f39 100644 --- a/test/test_init_args.py +++ b/test/test_init_args.py @@ -24,6 +24,11 @@ def test_singleton(self): assert 'bar' in r4 assert 'bar' not in r1 + def test_host_init_arg(self): + db = fakeredis.FakeStrictRedis(host='localhost') + db.set('foo', 'bar') + assert db.get('foo') == b'bar' + def test_from_url(self): db = fakeredis.FakeStrictRedis.from_url( 'redis://localhost:6379/0')