Closed decentral1se closed 7 years ago
I am using fakeredis as my Redis connection in my unit tests and it offers a decode_responses argument which avoid returning bytes:
decode_responses
bytes
>>> from fakeredis import FakeRedis >>> rds_without, rds_with = FakeRedis(), FakeRedis(decode_responses=True)) >>> rds_without['a'] = 1 >>> rds_with['a'] = 1 >>> rds_without['a'], rds_with['a'] (b'1', '1') >>> rds_with.keys() ['session:068678b2-4ecd-4747-91f4-624826d85447', 'a'] >>> rds_without.keys() [b'session:068678b2-4ecd-4747-91f4-624826d85447', b'a']
As far as I can see in my tests your RedisSessionInterface doesn't support this argument and everything comes back as bytes? In fact, I can't do lookups without bytes:
>>> session <RedisSession {'_permanent': True, b'foo': b'bar'}> >>> session['foo'] *** KeyError: 'foo'
Hmmmm, things just magically started working. I think it's my hangover but I can't be sure.
I am using fakeredis as my Redis connection in my unit tests and it offers a
decode_responses
argument which avoid returningbytes
:As far as I can see in my tests your RedisSessionInterface doesn't support this argument and everything comes back as bytes? In fact, I can't do lookups without
bytes
: