-
Notifications
You must be signed in to change notification settings - Fork 69
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
Easier session scoped mock (compatible with nested mocks) #133
Conversation
b8746ce is necessary to make |
url = 'mock://example.test/'
with requests_mock.Mocker() as global_mock:
global_mock.get(url, text='global')
session = requests.Session()
with requests_mock.Mocker(session=session) as session_mock:
session_mock.get(url, real_http=True)
text = session.get(url).text
Edit: last commit solved the issue |
Adding a wrapper function adds another layer to step through when debugging. Really all we want to do there is bind it to the instance so just do that up front. This is one of those moments you should just drop python 2.
Session is really the only argument i can think we'd allow to take on Mocker(). Also type check it. I know python, but still.
Resolve conflicts between #116 and #110.