From 0d8c08cd22018bbda2ba4eef07af49f42d5b9006 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Feb 2012 02:03:26 -0500 Subject: [PATCH] binary data upload bug test --- test_requests.py | 7 +++++-- test_requests_ext.py | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test_requests.py b/test_requests.py index b64b117..237550d 100755 --- a/test_requests.py +++ b/test_requests.py @@ -65,8 +65,6 @@ class RequestsTestSuite(TestSetup, unittest.TestCase): requests.patch requests.post - - def test_invalid_url(self): self.assertRaises(ValueError, get, 'hiwpefhipowhefopw') @@ -801,6 +799,11 @@ class RequestsTestSuite(TestSetup, unittest.TestCase): assert r.content is None assert isinstance(r.error, requests.exceptions.Timeout) + def test_upload_binary_data(self): + + r = requests.get(httpbin('post'), auth=('a', 'b'), data='\xff') + + if __name__ == '__main__': unittest.main() diff --git a/test_requests_ext.py b/test_requests_ext.py index 9e52a0d..8df101e 100644 --- a/test_requests_ext.py +++ b/test_requests_ext.py @@ -22,14 +22,17 @@ class RequestsTestSuite(unittest.TestCase): def test_addition(self): assert (1 + 1) == 2 + def test_ssl_hostname_ok(self): requests.get('https://github.com', verify=True) + def test_ssl_hostname_not_ok(self): requests.get('https://kennethreitz.com', verify=False) self.assertRaises(requests.exceptions.SSLError, requests.get, 'https://kennethreitz.com') + def test_ssl_hostname_session_not_ok(self): s = requests.session() @@ -39,6 +42,10 @@ class RequestsTestSuite(unittest.TestCase): s.get('https://kennethreitz.com', verify=False) + def test_binary_post(self): + utf8_string = (u'Smörgås').encode('utf-8') + requests.post('http://www.google.com/', data=utf8_string) + if __name__ == '__main__': unittest.main() -- 2.34.1