Merge branch 'master' of git://github.com/kennethreitz/requests

Conflicts:
	test_requests.py
This commit is contained in:
sprt
2013-01-24 18:36:53 +01:00
2 changed files with 12 additions and 11 deletions
+7 -4
View File
@@ -603,8 +603,11 @@ class Response(object):
return content
def json(self):
"""Returns the json-encoded content of a response, if any."""
def json(self, **kwargs):
"""Returns the json-encoded content of a response, if any.
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
"""
if not self.encoding and len(self.content) > 3:
# No encoding set. JSON RFC 4627 section 3 states we should expect
@@ -613,8 +616,8 @@ class Response(object):
# a best guess).
encoding = guess_json_utf(self.content)
if encoding is not None:
return json.loads(self.content.decode(encoding))
return json.loads(self.text or self.content)
return json.loads(self.content.decode(encoding), **kwargs)
return json.loads(self.text or self.content, **kwargs)
@property
def links(self):
+5 -7
View File
@@ -34,9 +34,6 @@ class RequestsTestCase(unittest.TestCase):
"""Teardown."""
pass
def test_assertion(self):
assert 1
def test_entry_points(self):
requests.session
@@ -76,10 +73,6 @@ class RequestsTestCase(unittest.TestCase):
self.assertEqual(request.url,
"http://example.com/path?key=value&a=b#fragment")
def test_HTTP_200_OK_GET(self):
r = requests.get(httpbin('get'))
self.assertEqual(r.status_code, 200)
def test_HTTP_200_OK_GET_ALTERNATIVE(self):
r = requests.Request('GET', httpbin('get'))
s = requests.Session()
@@ -281,6 +274,11 @@ class RequestsTestCase(unittest.TestCase):
self.assertTrue(hasattr(resp, 'hook_working'))
def test_links(self):
url = 'https://api.github.com/users/kennethreitz/repos?page=1&per_page=10'
r = requests.head(url=url)
self.assertEqual(r.links['next']['rel'], 'next')
if __name__ == '__main__':
unittest.main()