File: test_mock.py

package info (click to toggle)
python-fakeredis 2.29.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,772 kB
  • sloc: python: 19,002; sh: 8; makefile: 5
file content (17 lines) | stat: -rw-r--r-- 391 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from unittest.mock import patch

import redis

from fakeredis import FakeRedis


def test_mock():
    # Mock Redis connection
    def bar(redis_host: str, redis_port: int):
        redis.Redis(redis_host, redis_port)

    with patch("redis.Redis", FakeRedis):
        # Call function
        bar("localhost", 6000)

        # Related to #36 - this should fail if mocking Redis does not work