diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-05-27 14:38:37 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-05-27 14:39:10 -0400 |
commit | b036e30c3ed9be690e39f1658ac67ba9ace739e2 (patch) | |
tree | 7dc66377e72afc07b499bc1de24619e1c15f865b /tests | |
parent | 94c4daf4504d87ee396919ab2d67e8fc9b3a1982 (diff) | |
download | dogpile-cache-b036e30c3ed9be690e39f1658ac67ba9ace739e2.tar.gz |
Copy arguments passed to Redis
The Redis backend now creates a copy of the "arguments" dictionary passed
to it, before popping values out of it. This prevents the given
dictionary from losing its keys.
Change-Id: I17c5891cea82c2edaa09290ff974a261f909a811
(cherry picked from commit 4ca3e02f21338a3566697a84c12366b7b1950de5)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cache/_fixtures.py | 6 | ||||
-rw-r--r-- | tests/cache/test_redis_backend.py | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/tests/cache/_fixtures.py b/tests/cache/_fixtures.py index 04fdca3..15cbcf1 100644 --- a/tests/cache/_fixtures.py +++ b/tests/cache/_fixtures.py @@ -17,7 +17,8 @@ class _GenericBackendFixture(object): def setup_class(cls): try: backend_cls = _backend_loader.load(cls.backend) - backend = backend_cls(cls.config_args.get('arguments', {})) + arguments = cls.config_args.get('arguments', {}) + backend = backend_cls(arguments) except ImportError: pytest.skip("Backend %s not installed" % cls.backend) cls._check_backend_available(backend) @@ -64,7 +65,8 @@ class _GenericBackendFixture(object): def _backend(self): backend_cls = _backend_loader.load(self.backend) _config_args = self.config_args.copy() - self._backend_inst = backend_cls(_config_args.get('arguments', {})) + arguments = _config_args.get('arguments', {}) + self._backend_inst = backend_cls(arguments) return self._backend_inst diff --git a/tests/cache/test_redis_backend.py b/tests/cache/test_redis_backend.py index e8fdd2a..c91ac09 100644 --- a/tests/cache/test_redis_backend.py +++ b/tests/cache/test_redis_backend.py @@ -32,6 +32,7 @@ class RedisTest(_TestRedisConn, _GenericBackendTest): 'host': REDIS_HOST, 'port': REDIS_PORT, 'db': 0, + "foo": "barf" } } @@ -62,8 +63,7 @@ class RedisConnectionTest(TestCase): def _test_helper(self, mock_obj, expected_args, connection_args=None): if connection_args is None: - # The redis backend pops items from the dict, so we copy - connection_args = expected_args.copy() + connection_args = expected_args self.backend_cls(connection_args) mock_obj.assert_called_once_with(**expected_args) |