Skip to content

Commit 0ee4a94

Browse files
authored
[RedisContainer] Support decode_responses setting (#128)
* [RedisContainer] Support decode_responses setting Support decode_responses setting * modify as review suggests * modify as suggestions from review
1 parent 7068a45 commit 0ee4a94

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

testcontainers/redis.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1111
# License for the specific language governing permissions and limitations
1212
# under the License.
13+
1314
import redis as redis
1415

1516
from testcontainers.core.container import DockerContainer
@@ -28,8 +29,24 @@ def _connect(self):
2829
if not client.ping():
2930
raise Exception
3031

31-
def get_client(self):
32-
return redis.Redis(host=self.get_container_host_ip(), port=self.get_exposed_port(6379))
32+
def get_client(self, **kwargs):
33+
"""get redis client
34+
35+
Parameters
36+
----------
37+
kwargs: dict
38+
Keyword arguments passed to `redis.Redis`.
39+
40+
Returns
41+
-------
42+
client: redis.Redis
43+
Redis client to connect to the container.
44+
"""
45+
return redis.Redis(
46+
host=self.get_container_host_ip(),
47+
port=self.get_exposed_port(6379),
48+
**kwargs,
49+
)
3350

3451
def start(self):
3552
super().start()

0 commit comments

Comments
 (0)