question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTPretty breaking other URLs

See original GitHub issue

With the following test

@httprettified
def test_httpretty_should_not_override_other_urls():
    u"HTTPretty shouldn't break other URLs"

    HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo",
                           body="<root><baz /</root>")

    response = requests.get('http://google.com/')
    expect(response.status_code).to.equal(200)

I get

  File "HTTPretty/tests/functional/test_requests.py", line 153, in test_httpretty_should_not_override_other_urls
    response = requests.get('http://google.com/')
  File "HTTPretty/lib/python2.7/site-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "HTTPretty/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 289, in request
    history = [r for r in gen] if allow_redirects else []
  File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 133, in resolve_redirects
    proxies=proxies
  File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "HTTPretty/lib/python2.7/site-packages/requests/adapters.py", line 222, in send
    r.content
  File "HTTPretty/lib/python2.7/site-packages/requests/models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "HTTPretty/lib/python2.7/site-packages/requests/models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "HTTPretty/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 148, in read
    return self._fp.read(amt)
  File "python2.7/httplib.py", line 541, in read
    return self._read_chunked(amt)
  File "python2.7/httplib.py", line 592, in _read_chunked
    value.append(self._safe_read(amt))
  File "python2.7/httplib.py", line 649, in _safe_read
    raise IncompleteRead(''.join(s), amt)
IncompleteRead: IncompleteRead(532 bytes read)

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:2
  • Comments:28 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
m1schkacommented, Mar 29, 2016

I went back to using https://github.com/getsentry/responses, which is doing a better job at what I need

2reactions
m1schkacommented, Feb 9, 2016

I wouldn’t consider this issue as closed (as of 0.8.14) Similar to @anentropic, I get a BadStatusLine from inside the boto package even though I don’t mock those requests (because I’m using fakes3 for testing). I’m also using enable/disable manually, because I’m using it in test setup to activate a special api mock, which can occur at any given point in the tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTPretty Documentation
reset HTTPretty state (clean up registered urls and request␣ ... This analogy breaks down, though, because HTTPretty does not provide tools ...
Read more >
Httpretty causes socket to lose connection? - Stack Overflow
If I use httpretty.enable(allow_net_connect=False) (When ... _rfile.read(num_bytes) break except (IOError, OSError) as e: if e.errno ...
Read more >
HTTP Client Mocking Tool for Python - Morioh
@httpretty.activate def test_post_bodies(): url = 'http://httpbin.org/post' httpretty.register_uri(httpretty.POST, url, status=200) ...
Read more >
Requests-mock - jamielennox.net
HTTPretty is a way to mock HTTP responses at the socket level, so it is not dependant ... import requests >>> import requests_mock...
Read more >
Create Dynamic Links With URL Tag In Django - Vegibit
We do not want to hard code links in the template as they may break if the application changes in the future. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found