ENH: ensure we use custom adapters if mounted.

This allows responses to be used with custom adapters.

Tested on 2.7 with requests 2.4.1
Hrm in the pull request I see session.get_adapter, not self.get_adapter, are you sure this is correct?  


On Friday, September 19, 2014 at 12:27 PM, David Cournapeau wrote:

> In responses.py:
> > @@ -218,7 +218,9 @@ def _on_request(self, request, **kwargs): > > def start(self): > import mock > - self._patcher = mock.patch('requests.Session.send', self._on_request) > + def callback(session, requests, *a, **kwargs):  
> to answer your question, yes, the change is certainly needed.
> If you do the naive thing (which I did at first):
> def _on_request(self, request, *a, **kw): ... # self here is an instance of RequestsMock, not Session adapter = self.get_adapter(request.url)  
> you get an attribute error:
> test_responses.py:208: in test_custom_adapter run() responses.py:130: in wrapped return func(*args, **kwargs) test_responses.py:205: in run resp = session.get('http://example.com') .env/lib/python2.7/site-packages/requests-2.4.1-py2.7.egg/requests/sessions.py:463: in get return self.request('GET', url, **kwargs) .env/lib/python2.7/site-packages/requests-2.4.1-py2.7.egg/requests/sessions.py:451: in request resp = self.send(prep, **send_kwargs) responses.py:211: in _on_request adapter = self.get_adapter(request.url) E AttributeError: 'RequestsMock' object has no attribute 'get_adapter' ---------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------- <class 'responses.RequestsMock'>  
> With my function, because it "bypasses" the automatic passing of self, there is no such problem. I don't know of a simpler way to achieve that.
>  
> —
> Reply to this email directly or view it on GitHub (https://github.com/dropbox/responses/pull/33/files#r17804343).
>  
>  
>