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

1.8 does not work as a monkey patch #29

Closed
PeteDouma opened this issue Jun 2, 2022 · 4 comments
Closed

1.8 does not work as a monkey patch #29

PeteDouma opened this issue Jun 2, 2022 · 4 comments
Labels
bug Something isn't working triage Needs to be triaged

Comments

@PeteDouma
Copy link

PeteDouma commented Jun 2, 2022

I was using version 1.7.1 and this code worked

import redis
import arrow
import fakeredis

from datetime import date


def test_state(monkeypatch):
    monkeypatch.setattr(redis,'Redis',fakeredis.FakeRedis )

    from ..src.status import SystemState
    state = SystemState()

    print(state.serial)
    assert state.version == '2.0'
    assert state.timezone == 'America/New_York'
    state.lights = 'off'
    value, when = state.lights
    assert value == 'off'
 

However in 1.8 I get a connection pool error

@PeteDouma PeteDouma added the bug Something isn't working label Jun 2, 2022
@cunla
Copy link
Owner

cunla commented Jun 3, 2022

Can you mention python version, dependencies, and stacktrace?

@cunla cunla added the triage Needs to be triaged label Jun 3, 2022
@PeteDouma
Copy link
Author

PeteDouma commented Jun 6, 2022

python version 3.9 on a Raspberry Pi Zero
Version 1.8

src/status.py:16: in init
self.redis = redis.Redis(decode_responses=True)

self = <[AttributeError("'FakeRedis' object has no attribute 'connection_pool'") raised in repr()] FakeRedis object at 0x751f8d48>, server = None, connected = True, args = ()
kwargs = {'decode_responses': True}
default_args = odict_values([<Parameter "self">, <Parameter "*args">, <Parameter "server=None">, <Parameter "connected=True">, <Parameter "**kwargs">])
kwds = {'connected': True, 'decode_responses': True, 'server': None}

def __init__(self, *args, server=None, connected=True, **kwargs):
    # Interpret the positional and keyword arguments according to the
    # version of redis in use.
    default_args = inspect.signature(redis.Redis.__init__).parameters.values()
    kwds = {p.name: p.default for p in default_args if p.default != inspect._empty}
    kwds.update(kwargs)
    # bound = _ORIG_SIG.bind(*args, **params)
    # kwds = bound.arguments['kwds']
  if not kwds['connection_pool']:

E KeyError: 'connection_pool'

../../../lib/python3.9/site-packages/fakeredis/_server.py:2825: KeyError

@cunla
Copy link
Owner

cunla commented Jun 9, 2022

Update to latest fakeredis version.

@PeteDouma
Copy link
Author

Thanks

@cunla cunla closed this as completed Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants