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

Add compatibility with requests-mock #87

Closed
1kastner opened this issue Mar 14, 2017 · 6 comments · Fixed by #183
Closed

Add compatibility with requests-mock #87

1kastner opened this issue Mar 14, 2017 · 6 comments · Fixed by #183

Comments

@1kastner
Copy link

When I want to test my programm with requests_mocks, the program runs into recursion. A small example can be found at this gist.

@jordansamuels
Copy link

This is an issue for me as well.

@bachya
Copy link

bachya commented Aug 3, 2017

Me too. For reference, the CacheControl library (a different approach to caching Requests calls) works fine with requests-mock.

@Demborg
Copy link

Demborg commented Mar 11, 2019

Just ran into this myself

@reclosedev reclosedev added the bug label Apr 13, 2019
@JWCook
Copy link
Member

JWCook commented Feb 25, 2021

It appears that both requests-cache and requests-mock work by patching requests.Session. So whichever gets called last will override the other.

It may be possible to combine both by refactoring CachedSession to be usable as a Mixin class, and add a function to requests-cache that takes a Session object patched by requests-mock and returns a new Session object with the requests-mock mixin added. There might be better solutions, though.

Is this something that anyone would like to submit a PR for?

@JWCook JWCook changed the title Interference with requests-mock Add compatibility with requests-mock Feb 25, 2021
@JWCook JWCook added this to the v0.6 milestone Mar 4, 2021
@JWCook
Copy link
Member

JWCook commented Mar 4, 2021

Since this is the same fundamental issue as #158 (which I am working on now), I'm going to close this issue.

@JWCook
Copy link
Member

JWCook commented Mar 5, 2021

Done. See examples in PR #183.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants