Skip to content

Conversation

@bmerry
Copy link
Collaborator

@bmerry bmerry commented Aug 1, 2021

Adds support for aioredis 2. Since this is a complete rewrite with a different API, there are different backend modules for each, and the appropriate one is imported. _aioredis1.py is essentially the old aioredis.py, minus some bits of common code that were refactored into async.py.

pool.connection_kwargs['server'] = server
for key in ['password', 'host', 'port', 'path']:
if key in pool.connection_kwargs:
del pool.connection_kwargs[key]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't really related, but it's no longer necessary now that FakeConnection can absorb arbitrary kwargs.



def test_hmsetset_empty_raises_error(r):
def test_hmset_empty_raises_error(r):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file aren't really related - just a typo/search-replace error that I spotted.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.5%) to 93.548% when pulling f585384 on aioredis2 into f8b5936 on master.

sburba added a commit to ttbud/ttbud that referenced this pull request Aug 1, 2021
Waiting for jamesls/fakeredis#304 to release to
finish making the tests work
sburba added a commit to ttbud/ttbud that referenced this pull request Aug 2, 2021
Waiting for jamesls/fakeredis#304 to release to
finish making the tests work
aioredis2 = aioredis.__version__ >= distutils.version.StrictVersion('2.0.0a1')
pytestmark = [
pytest.mark.asyncio,
pytest.mark.skipif(not aioredis2, reason="Test is only applicable to aioredis 2.x")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pytest.mark.skipif(not aioredis2, reason="Test is only applicable to aioredis 2.x")
pytest.mark.skipif(not aioredis2, reason="Test is only applicable to aioredis 1.x")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit tests in test_aioredis2.py are presumably meant for aioredis 2.x, so I think the original sense is correct.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test is being skipped here if it's not marked as being for aioredis 2.x so I think the reason should be what I've proposed? Or am I missing something?

Copy link
Collaborator

@ludwigschwardt ludwigschwardt Aug 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I read it is that not aioredis2 means that aioredis 1 is installed. Then all tests in test_aioredis2.py will be skipped, because they are meant to be run with aioredis 2.x.

A similar (but inverse) pattern is used in test_aioredis1.py.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah. Sorry. 😅

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the confusion on my side came from the fact that I thought that in the 1.x tests the message was also talking about 2.x

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries - I first had to figure out that pytestmark actually does something... Ah, the magic of pytest 😂

Copy link
Collaborator

@ludwigschwardt ludwigschwardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an in-depth review, but a quick scan and crosscheck with v1.



class FakeReader:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why don't you need a Reader with aioredis 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fakeredis is a bit asymmetric (and one day I might try to address that): commands get serialised by aioredis/redis-py and parsed by fakeredis, but responses are kept as structured Python objects and the response parsing is bypassed.

import fakeredis.aioredis


aioredis2 = aioredis.__version__ >= distutils.version.StrictVersion('2.0.0a1')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered packaging or is it not worth the extra install?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I see distutils is going to be deprecated in Python 3.10 and packaging will be recommended. So I might as well make the change now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I'll make a separate PR so as not to hold up this release.

@bmerry bmerry merged commit 4ab4694 into master Aug 16, 2021
@bmerry bmerry deleted the aioredis2 branch August 16, 2021 07:36
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

Successfully merging this pull request may close these issues.

5 participants