httmock
httmock copied to clipboard
A mocking library for requests
Right now if `content=None` when `stream=True`, then you get: ``` File "/Users/alex/.virtualenvs/media/lib/python2.7/site-packages/httmock.py", line 194, in intercept stream=kwargs.get('stream', False)) File "/Users/alex/.virtualenvs/media/lib/python2.7/site-packages/httmock.py", line 63, in response res.raw = BytesIO(content) TypeError: must be...
Hi! I find that the `raw.read` would raise `TypeError` when I call `raw.read(decode_content=True)` in my project. Here is the error message: ``` TypeError: read() got an unexpected keyword argument 'decode_content'...
I have a set of increasingly complicated data from an outside platform I need to mock. I would like to simplify that with fixtures, if possible. Are there any recommended...
I ran into this issue today, where everything worked in tests but failed when not mocked. ``` >>> import requests >>> requests.post('http://example.com', 2.0) TypeError: 'float' object is not iterable ```...
The latest version - https://github.com/patrys/httmock/blob/master/httmock.py#L109 When running with `requests-1.2.0`, got the following:- ``` Traceback (most recent call last): File "/home/kamal/clean/marimore_m7msgezsms/branches/219-private-routing-ordered/src/m7msgezsms/apps/ezsms_api_test/tests/tests_call_api.py", line 376, in test_valid_update_call_status with httmock.HTTMock(_get_response): File "/home/kamal/clean/marimore_m7msgezsms/branches/219-private-routing-ordered/eggs/httmock-1.2.3-py2.7.egg/httmock.py", line 109,...
Response objects in requests are documented to contain a `raw` attribute that is a file-like object. When the request is made with `stream=True`, the `raw` attribute can be read to...
Requests do this using `extract_cookies_to_jar(self.cookies, request, r.raw)` [requests/sessions.py#L583-L589](https://github.com/kennethreitz/requests/blob/2fc6e8a894a5378dd16b2653df9ccf875d0bddf8/requests/sessions.py#L583-L589) But `raw` is always `None` now #23. Anyway, `cookies.update(...)` works fine.
Outbox?
It would be pretty handy to have an outbox where all requests that received a mock response would be stored for reference later by a test, similar to [Django's Email...
The `content` attribute is always encoded as `"utf-8"` ([source](https://github.com/patrys/httmock/blob/master/httmock.py#L43)). However, we've noticed that `https://google.com/` (as of 9/29) now returns content encoded as 'ISO-8859-1'. This breaks some tests that do an...
This MR fixes #67. Changes: - Use encoding from headers to encode the content attributes - Add a regression test