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
Mocket fails when there are Redis calls using hiredis
#147
Comments
Hi @WisdomPill, I am having a look at that. Thanks for the feedback. |
The other thing is: I have to create a dummy project with Django, your script cannot work without it. |
Hello @mindflayer, |
I launched a |
What |
All
|
I am using the same redis version.
|
Thanks, that would help. :) |
With just the requirements of my previous comment it seems to work, but if I copy the requirements of the project in which there is the issue it happens again. |
It has to do with |
That's quite strange, AFAIK |
Let me know in case you feel I can be of help. |
I did some digging and removed django. |
When using At the moment the alternatives you have are:
from mocket import Mocket, Mocketizer
def test_random_url_with_redis(redis_client: Redis):
url = "http://www.example.com"
Entry.single_register(Entry.GET, url)
redis_client.set("key", "value")
with Mocketizer():
requests.get(url)
assert Mocket.has_requests()
I'll do my best to understand how to fix the error, but sometimes it takes a while. |
hiredis
Okay, thanks for the explanation. P.S. I wanted to make another point in why I am not using |
I understand your point of view and I believe it makes sense, especially if your logic can be different depending on something cached or not, but also consider that a cache, by definition, should not be a "blocker" and your application should be able to work when Redis is not available, it's just there as an additional layer which helps to speed up the flow. |
Thank you so much for your help, btw. |
Describe the bug
I have a
django
based software that makes http requests usingrequests
and usesdjango-redis
to store some data of what it has fetched. I have noticed that if the first network call in aTestCase
is forredis
thenmocket
mocks redis, otherwise it mocks onlyrequests
.To Reproduce
will throw an exception
If you swap names of the test functions it works as expected.
Expected behavior
Choose what to mock with some flag.
Additional context
It happens in macOS and ubuntu, with python3.7 and also 3.8
The text was updated successfully, but these errors were encountered: