patrys/httmock — pull request #9 by gmr (2013-09-26 00:05:41+00:00)
Title: Python 3 JSON dump encoding test

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