Skip to content

Commit

Permalink
[RedisContainer] Support decode_responses setting (#128)
Browse files Browse the repository at this point in the history
* [RedisContainer] Support decode_responses setting

Support decode_responses setting

* modify as review suggests

* modify as suggestions from review
  • Loading branch information
ysde committed Mar 5, 2021
1 parent 7068a45 commit 0ee4a94
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions testcontainers/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import redis as redis

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

def get_client(self):
return redis.Redis(host=self.get_container_host_ip(), port=self.get_exposed_port(6379))
def get_client(self, **kwargs):
"""get redis client
Parameters
----------
kwargs: dict
Keyword arguments passed to `redis.Redis`.
Returns
-------
client: redis.Redis
Redis client to connect to the container.
"""
return redis.Redis(
host=self.get_container_host_ip(),
port=self.get_exposed_port(6379),
**kwargs,
)

def start(self):
super().start()
Expand Down

0 comments on commit 0ee4a94

Please sign in to comment.