Skip to content

Commit

Permalink
Fix broken awsrequest tests on certain python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
joguSD committed Aug 20, 2018
1 parent 133f810 commit 381d664
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion botocore/awsrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def text(self):
if encoding:
return self.content.decode(encoding)
else:
return self.content.decode()
return self.content.decode('utf-8')


class _HeaderKey(object):
Expand Down
15 changes: 9 additions & 6 deletions tests/unit/test_awsrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def test_can_prepare_url_params(self):
self.assertEqual(prepared_request.url, 'http://example.com/?foo=bar')

def test_can_prepare_dict_body(self):
body = {'foo': 'baz', 'dead': 'beef'}
body = {'dead': 'beef'}
request = AWSRequest(url='http://example.com/', data=body)
prepared_request = request.prepare()
self.assertEqual(prepared_request.body, 'foo=baz&dead=beef')
self.assertEqual(prepared_request.body, 'dead=beef')

def test_can_prepare_empty_body(self):
request = AWSRequest(url='http://example.com/', data=b'')
Expand Down Expand Up @@ -458,7 +458,8 @@ def test_state_reset_on_connection_close(self):
wait_mock.return_value = True

conn.request('GET', '/bucket/foo', b'body',
{'Expect': '100-continue'})
{'Expect': b'100-continue'})
self.assertEqual(wait_mock.call_count, 1)
response = conn.getresponse()
self.assertEqual(response.status, 500)

Expand All @@ -480,7 +481,7 @@ def test_state_reset_on_connection_close(self):
conn.request('GET', '/bucket/foo', b'body',
{'Expect': b'100-continue'})
# Assert that we waited for the 100-continue response
self.assertEqual(wait_mock.call_count, 1)
self.assertEqual(wait_mock.call_count, 2)
response = conn.getresponse()
# This should be 200. If it's a 500 then
# the prior response was leaking into our
Expand Down Expand Up @@ -647,9 +648,11 @@ def test_del_insensitive(self):
def test_iteration(self):
self.headers['FOO'] = 'bar'
self.headers['dead'] = 'beef'
self.assertEqual(list(self.headers), ['FOO', 'dead'])
self.assertIn('FOO', list(self.headers))
self.assertIn('dead', list(self.headers))
headers_items = list(self.headers.items())
self.assertEqual(headers_items, [('FOO', 'bar'), ('dead', 'beef')])
self.assertIn(('FOO', 'bar'), headers_items)
self.assertIn(('dead', 'beef'), headers_items)


if __name__ == "__main__":
Expand Down

0 comments on commit 381d664

Please sign in to comment.