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

Fix import used in GenericCommandsMixin.randomkey #135

Merged
merged 1 commit into from
Mar 31, 2023
Merged

Fix import used in GenericCommandsMixin.randomkey #135

merged 1 commit into from
Mar 31, 2023

Conversation

mudetz
Copy link
Contributor

@mudetz mudetz commented Mar 31, 2023

Purpose

Fix a module import used un GenericCommandsMixin.randomkey

Issue

When executing the RANDOMKEY command with FakeRedis, an exception is thrown.
AttributeError: 'builtin_function_or_method' object has no attribute 'choice'

This issue was introduced in v1.10.0

Steps to reproduce

Execute the .randomkey() method (or command) using FakeRedis

Assume this pytest test

def test_randomkey_returns_existing_key(r):
    # populate db
    r.set("foo", 1)
    r.set("bar", 2)
    r.set("baz", 3)

    # request random key
    assert r.randomkey() in ("foo", "bar", "baz")  # boom!

@cunla
Copy link
Owner

cunla commented Mar 31, 2023

Interestingly there were no tests for this method.

Thanks for this PR - good catch

@cunla cunla added the bug Something isn't working label Mar 31, 2023
@cunla cunla merged commit 54cb429 into cunla:master Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants