If relying on the response content auto-serialization of dict to JSON, Python 3 evaluations of the response content fail with a type error due to how requests.utils.guess_json_utf() attempts to figure out if the content is UTF-8 or not.
This commit adds a unit test that fails when using this functionality, causing TypeError exception:
======================================================================
ERROR: test_get (tests.Python3EncodingTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/gmr/Dropbox/Source/httmock/tests.py", line 183, in test_get
self.assertEqual(self.content, response.json())
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/requests/models.py", line 687, in json
encoding = guess_json_utf(self.content)
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/requests/utils.py", line 518, in guess_json_utf
nullcount = sample.count(_null)
TypeError: Can't convert 'bytes' object to str implicitly
Also, I have included the test in the next pull request as well, I did this so you could test in isolation without the fix. I would prefer if you did not apply this pull request but #10.
If relying on the response content auto-serialization of dict to JSON, Python 3 evaluations of the response content fail with a type error due to how requests.utils.guess_json_utf() attempts to figure out if the content is UTF-8 or not.
This commit adds a unit test that fails when using this functionality, causing TypeError exception: