Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'FakeRedis' object has no attribute 'cache' #313

Closed
radugaf opened this issue Oct 21, 2021 · 2 comments
Closed

'FakeRedis' object has no attribute 'cache' #313

radugaf opened this issue Oct 21, 2021 · 2 comments

Comments

@radugaf
Copy link

radugaf commented Oct 21, 2021

While testing a redis walrus app in which I have the following function:

@cached_property
    def redis_connection(self):
        conn = self.db_factory(host=self.redis_host, port=self.redis_port)
        return conn.cache()

My test looks like

def test_dem_qe_cache_redis_connection():
    redis_host = 'localhost'
    redis_port = 6379
    db_factory = fakeredis.FakeRedis

    object = Cache(
        db_factory = db_factory,
        redis_host = redis_host, 
        redis_port = redis_port
    )

    assert object.redis_connection is not None

The output of the test is:

    @cached_property
    def redis_connection(self):
        conn = self.db_factory(host=self.redis_host, port=self.redis_port)
>       return conn.cache()
E       AttributeError: 'FakeRedis' object has no attribute 'cache'
@bmerry
Copy link
Collaborator

bmerry commented Oct 21, 2021

I'm not sure why you'd expect a FakeRedis object to have a cache attribute. A Redis object doesn't have one either.

@bmerry
Copy link
Collaborator

bmerry commented Nov 7, 2021

Closing due to lack of further feedback.

@bmerry bmerry closed this as completed Nov 7, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants