HTTPretty not working with Requests?
You want to test your HTTP client code, so you've written something like:
@httprettified
def test_example():
HTTPretty.register_uri(HTTPretty.GET,
'http://example.com',
body='snerble')
response = requests.get('http://example.com')
self.assertEquals(response.text, 'snerble')
but it's not working? Requests
is adding a trailing slash to your URI, preventing it from matching the URI you've registered.
You need to register the URI like so:
HTTPretty.register_uri(HTTPretty.GET,
'http://example.com/',
body='snerble')
Written by Clay McClure
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Related Tags
#python
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#