lost in merge
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 9697290 · Browse files · 2 files·+737 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+737 added−0 removed
- tests:+737 added−0 removed
Provenance
- Commit
e9f94e6- Tree
adace54- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
9697290
2 files changed+737 added−0 removed
added:tests/api_tests.py+209 added
1+#!/usr/bin/env python2+# -*- coding: utf-8 -*-3+import unittest4+import mock5+import sys6+import os7+sys.path.append(os.getcwd())8+9+try:10+ import omnijson as json11+except ImportError:12+ import json13+14+import requests15+from requests.models import Response16+17+class RequestsAPIUnitTests(unittest.TestCase):18+ """Requests API unit test cases."""19+20+ def setUp(self):21+ pass22+23+24+ def tearDown(self):25+ """Teardown."""26+ pass27+28+29+ @mock.patch('requests.api.dispatch_hook')30+ @mock.patch('requests.api.Request')31+ @mock.patch('requests.api.cookiejar_from_dict')32+ def test_request(self, mock_cjar, mock_request, mock_hook):33+ args = dict(34+ method = None,35+ url = None,36+ data = None,37+ params = None,38+ headers = None,39+ cookiejar = None,40+ files = None,41+ auth = None,42+ timeout = 1,43+ allow_redirects = None,44+ proxies = None,45+ )46+ hooks = {'args': args, 'pre_request': mock_request,47+ 'post_request': mock_request, 'response': 'response'}48+ sideeffect = lambda x,y,z: hooks[x]49+ mock_cjar.return_value = None50+ mock_request.send = mock.Mock(return_value={})51+ mock_request.response = "response"52+ mock_hook.side_effect = sideeffect53+54+ r = requests.request('get','http://google.com')55+56+57+ mock_cjar.assert_called_once_with({})58+ mock_hook.assert_called__with('args', None, args)59+ mock_request.assert_called_once_with(**args)60+ mock_hook.assert_called__with('pre_request', None, mock_request)61+ mock_request.send.assert_called_once_with()62+ mock_hook.assert_called__with('post_request', None, mock_request)63+ mock_hook.assert_called__with('response', None, mock_request)64+ self.assertEqual(r, "response")65+66+67+68+ @mock.patch('requests.api.request')69+ def test_http_get(self, mock_request):70+ mock_request.return_value = Response()71+ requests.get('http://google.com')72+ mock_request.assert_called_once_with('get', 'http://google.com',73+ allow_redirects= True)74+75+ @mock.patch('requests.api.request')76+ def test_http_get_with_kwargs(self, mock_request):77+ mock_request.return_value = Response()78+ requests.get('http://google.com',79+ params="params", data="data", headers="headers",80+ cookies="cookies",81+ files="files", auth="auth", timeout="timeout",82+ allow_redirects=False,83+ proxies="proxies", hooks="hooks")84+ mock_request.assert_called_once_with('get', 'http://google.com',85+ params="params", data="data", headers="headers",86+ cookies="cookies",87+ files="files", auth="auth", timeout="timeout",88+ allow_redirects=False,89+ proxies="proxies", hooks="hooks")90+91+ @mock.patch('requests.api.request')92+ def test_http_head(self, mock_request):93+ mock_request.return_value = Response()94+ requests.head('http://google.com')95+ mock_request.assert_called_once_with('head', 'http://google.com',96+ allow_redirects= True)97+98+ @mock.patch('requests.api.request')99+ def test_http_head_with_kwargs(self, mock_request):100+ mock_request.return_value = Response()101+ requests.head('http://google.com',102+ params="params", data="data", headers="headers",103+ cookies="cookies",104+ files="files", auth="auth", timeout="timeout",105+ allow_redirects=False,106+ proxies="proxies", hooks="hooks")107+ mock_request.assert_called_once_with('head', 'http://google.com',108+ params="params", data="data", headers="headers",109+ cookies="cookies",110+ files="files", auth="auth", timeout="timeout",111+ allow_redirects=False,112+ proxies="proxies", hooks="hooks")113+114+ @mock.patch('requests.api.request')115+ def test_http_post(self, mock_request):116+ mock_request.return_value = Response()117+ requests.post('http://google.com', {})118+ mock_request.assert_called_once_with('post', 'http://google.com',119+ data= {})120+121+ @mock.patch('requests.api.request')122+ def test_http_post_with_kwargs(self, mock_request):123+ mock_request.return_value = Response()124+ requests.post('http://google.com',125+ params="params", data="data", headers="headers",126+ cookies="cookies",127+ files="files", auth="auth", timeout="timeout",128+ allow_redirects=False,129+ proxies="proxies", hooks="hooks")130+ mock_request.assert_called_once_with('post', 'http://google.com',131+ params="params", data="data", headers="headers",132+ cookies="cookies",133+ files="files", auth="auth", timeout="timeout",134+ allow_redirects=False,135+ proxies="proxies", hooks="hooks")136+137+138+ @mock.patch('requests.api.request')139+ def test_http_put(self, mock_request):140+ mock_request.return_value = Response()141+ requests.put('http://google.com', {})142+ mock_request.assert_called_once_with('put', 'http://google.com',143+ data= {})144+145+ @mock.patch('requests.api.request')146+ def test_http_put_with_kwargs(self, mock_request):147+ mock_request.return_value = Response()148+ requests.put('http://google.com',149+ params="params", data="data", headers="headers",150+ cookies="cookies",151+ files="files", auth="auth", timeout="timeout",152+ allow_redirects=False,153+ proxies="proxies", hooks="hooks")154+ mock_request.assert_called_once_with('put', 'http://google.com',155+ params="params", data="data", headers="headers",156+ cookies="cookies",157+ files="files", auth="auth", timeout="timeout",158+ allow_redirects=False,159+ proxies="proxies", hooks="hooks")160+161+162+ @mock.patch('requests.api.request')163+ def test_http_patch(self, mock_request):164+ mock_request.return_value = Response()165+ requests.patch('http://google.com', {})166+ mock_request.assert_called_once_with('patch', 'http://google.com',167+ data= {})168+169+ @mock.patch('requests.api.request')170+ def test_http_patch_with_kwargs(self, mock_request):171+ mock_request.return_value = Response()172+ requests.patch('http://google.com',173+ params="params", data="data", headers="headers",174+ cookies="cookies",175+ files="files", auth="auth", timeout="timeout",176+ allow_redirects=False,177+ proxies="proxies", hooks="hooks")178+ mock_request.assert_called_once_with('patch', 'http://google.com',179+ params="params", data="data", headers="headers",180+ cookies="cookies",181+ files="files", auth="auth", timeout="timeout",182+ allow_redirects=False,183+ proxies="proxies", hooks="hooks")184+185+ @mock.patch('requests.api.request')186+ def test_http_delete(self, mock_request):187+ mock_request.return_value = Response()188+ requests.delete('http://google.com')189+ mock_request.assert_called_once_with('delete', 'http://google.com')190+191+ @mock.patch('requests.api.request')192+ def test_http_delete_with_kwargs(self, mock_request):193+ mock_request.return_value = Response()194+ requests.delete('http://google.com',195+ params="params", data="data", headers="headers",196+ cookies="cookies",197+ files="files", auth="auth", timeout="timeout",198+ allow_redirects=False,199+ proxies="proxies", hooks="hooks")200+ mock_request.assert_called_once_with('delete', 'http://google.com',201+ params="params", data="data", headers="headers",202+ cookies="cookies",203+ files="files", auth="auth", timeout="timeout",204+ allow_redirects=False,205+ proxies="proxies", hooks="hooks")206+207+208+if __name__ == '__main__':209+ unittest.main()added:tests/integration_tests.py+528 added
1+#!/usr/bin/env python2+# -*- coding: utf-8 -*-3+4+from __future__ import with_statement5+6+import unittest7+import cookielib8+9+try:10+ import omnijson as json11+except ImportError:12+ import json13+14+import requests15+16+from requests.sessions import Session17+from requests.utils import curl_from_request18+19+20+HTTPBIN_URL = 'http://httpbin.org/'21+HTTPSBIN_URL = 'https://httpbin.herokuapp.com/'22+23+# HTTPBIN_URL = 'http://staging.httpbin.org/'24+# HTTPSBIN_URL = 'https://httpbin-staging.ep.io/'25+26+27+def httpbin(*suffix):28+ """Returns url for HTTPBIN resource."""29+30+ return HTTPBIN_URL + '/'.join(suffix)31+32+33+def httpsbin(*suffix):34+ """Returns url for HTTPSBIN resource."""35+36+ return HTTPSBIN_URL + '/'.join(suffix)37+38+39+SERVICES = (httpbin, httpsbin)40+41+42+43+class RequestsTestSuite(unittest.TestCase):44+ """Requests test cases."""45+46+ # It goes to eleven.47+ _multiprocess_can_split_ = True48+49+ def setUp(self):50+ pass51+52+ def tearDown(self):53+ pass54+55+ def test_invalid_url(self):56+ self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')57+58+ def test_HTTP_200_OK_GET(self):59+ r = requests.get(httpbin('/'))60+ self.assertEqual(r.status_code, 200)61+62+ def test_HTTP_302_ALLOW_REDIRECT_GET(self):63+ r = requests.get(httpbin('redirect', '1'))64+ self.assertEqual(r.status_code, 200)65+66+ def test_HTTP_302_GET(self):67+ r = requests.get(httpbin('redirect', '1'), allow_redirects=False)68+ self.assertEqual(r.status_code, 302)69+70+ def test_HTTPS_200_OK_GET(self):71+ r = requests.get(httpsbin('/'))72+ self.assertEqual(r.status_code, 200)73+74+75+ def test_HTTP_200_OK_GET_WITH_PARAMS(self):76+ heads = {'User-agent': 'Mozilla/5.0'}77+78+ r = requests.get(httpbin('user-agent'), headers=heads)79+80+ assert heads['User-agent'] in r.content81+ self.assertEqual(r.status_code, 200)82+83+84+ def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):85+ heads = {'User-agent': 'Mozilla/5.0'}86+87+ r = requests.get(httpbin('get') + '?test=true', params={'q': 'test'}, headers=heads)88+ self.assertEqual(r.status_code, 200)89+90+91+ def test_user_agent_transfers(self):92+ """Issue XX"""93+94+ heads = {95+ 'User-agent':96+ 'Mozilla/5.0 (github.com/kennethreitz/requests)'97+ }98+99+ r = requests.get(httpbin('user-agent'), headers=heads);100+ self.assertTrue(heads['User-agent'] in r.content)101+102+ heads = {103+ 'user-agent':104+ 'Mozilla/5.0 (github.com/kennethreitz/requests)'105+ }106+107+ r = requests.get(httpbin('user-agent'), headers=heads);108+ self.assertTrue(heads['user-agent'] in r.content)109+110+111+ def test_HTTP_200_OK_HEAD(self):112+ r = requests.head(httpbin('/'))113+ self.assertEqual(r.status_code, 200)114+115+116+ def test_HTTPS_200_OK_HEAD(self):117+ r = requests.head(httpsbin('/'))118+ self.assertEqual(r.status_code, 200)119+120+121+ def test_HTTP_200_OK_PUT(self):122+ r = requests.put(httpbin('put'))123+ self.assertEqual(r.status_code, 200)124+125+126+ def test_HTTPS_200_OK_PUT(self):127+ r = requests.put(httpsbin('put'))128+ self.assertEqual(r.status_code, 200)129+130+131+ def test_HTTP_200_OK_PATCH(self):132+ r = requests.patch(httpbin('patch'))133+ self.assertEqual(r.status_code, 200)134+135+136+ def test_HTTPS_200_OK_PATCH(self):137+ r = requests.patch(httpsbin('patch'))138+ self.assertEqual(r.status_code, 200)139+140+141+ def test_AUTH_HTTP_200_OK_GET(self):142+143+ for service in SERVICES:144+145+ auth = ('user', 'pass')146+ url = service('basic-auth', 'user', 'pass')147+148+ r = requests.get(url, auth=auth)149+ # print r.__dict__150+ self.assertEqual(r.status_code, 200)151+152+153+ r = requests.get(url)154+ self.assertEqual(r.status_code, 200)155+156+157+ def test_POSTBIN_GET_POST_FILES(self):158+159+ for service in SERVICES:160+161+ url = service('post')162+ post = requests.post(url).raise_for_status()163+164+ post = requests.post(url, data={'some': 'data'})165+ self.assertEqual(post.status_code, 200)166+167+ post2 = requests.post(url, files={'some': open('test_requests.py')})168+ self.assertEqual(post2.status_code, 200)169+170+ post3 = requests.post(url, data='[{"some": "json"}]')171+ self.assertEqual(post3.status_code, 200)172+173+174+ def test_POSTBIN_GET_POST_FILES_WITH_PARAMS(self):175+176+ for service in SERVICES:177+178+ url = service('post')179+ post = requests.post(url,180+ files={'some': open('test_requests.py')},181+ data={'some': 'data'})182+183+ self.assertEqual(post.status_code, 200)184+185+186+ def test_POSTBIN_GET_POST_FILES_WITH_HEADERS(self):187+188+ for service in SERVICES:189+190+ url = service('post')191+192+ post2 = requests.post(url,193+ files={'some': open('test_requests.py')},194+ headers = {'User-Agent': 'requests-tests'})195+196+ self.assertEqual(post2.status_code, 200)197+198+199+ def test_nonzero_evaluation(self):200+201+ for service in SERVICES:202+203+ r = requests.get(service('status', '500'))204+ self.assertEqual(bool(r), False)205+206+ r = requests.get(service('/'))207+ self.assertEqual(bool(r), True)208+209+210+ def test_request_ok_set(self):211+212+ for service in SERVICES:213+214+ r = requests.get(service('status', '404'))215+ self.assertEqual(r.ok, False)216+217+218+ def test_status_raising(self):219+ r = requests.get(httpbin('status', '404'))220+ self.assertRaises(requests.HTTPError, r.raise_for_status)221+222+ r = requests.get(httpbin('status', '200'))223+ self.assertFalse(r.error)224+ r.raise_for_status()225+226+227+ def test_cookie_jar(self):228+229+ jar = cookielib.CookieJar()230+ self.assertFalse(jar)231+232+ url = httpbin('cookies', 'set', 'requests_cookie', 'awesome')233+ r = requests.get(url, cookies=jar)234+ self.assertTrue(jar)235+236+ cookie_found = False237+ for cookie in jar:238+ if cookie.name == 'requests_cookie':239+ self.assertEquals(cookie.value, 'awesome')240+ cookie_found = True241+ self.assertTrue(cookie_found)242+243+ r = requests.get(httpbin('cookies'), cookies=jar)244+ self.assertTrue('awesome' in r.content)245+246+247+ def test_decompress_gzip(self):248+249+ r = requests.get(httpbin('gzip'))250+ r.content.decode('ascii')251+252+253+ def test_unicode_get(self):254+255+ for service in SERVICES:256+257+ url = service('/')258+259+ requests.get(url, params={'foo': u'føø'})260+ requests.get(url, params={u'føø': u'føø'})261+ requests.get(url, params={'føø': 'føø'})262+ requests.get(url, params={'foo': u'foo'})263+ requests.get(service('ø'), params={'foo': u'foo'})264+265+266+ def test_httpauth_recursion(self):267+268+ http_auth = ('user', 'BADpass')269+270+ for service in SERVICES:271+ r = requests.get(service('basic-auth', 'user', 'pass'), auth=http_auth)272+ self.assertEquals(r.status_code, 401)273+274+275+ def test_settings(self):276+277+ def test():278+ r = requests.get(httpbin(''))279+ r.raise_for_status()280+281+ with requests.settings(timeout=0.0000001):282+ self.assertRaises(requests.Timeout, test)283+284+ with requests.settings(timeout=100):285+ requests.get(httpbin(''))286+287+288+ def test_urlencoded_post_data(self):289+290+ for service in SERVICES:291+292+ r = requests.post(service('post'), data=dict(test='fooaowpeuf'))293+294+ self.assertEquals(r.status_code, 200)295+ self.assertEquals(r.headers['content-type'], 'application/json')296+ self.assertEquals(r.url, service('post'))297+298+ rbody = json.loads(r.content)299+300+ self.assertEquals(rbody.get('form'), dict(test='fooaowpeuf'))301+ self.assertEquals(rbody.get('data'), '')302+303+304+ def test_nonurlencoded_post_data(self):305+306+ for service in SERVICES:307+308+ r = requests.post(service('post'), data='fooaowpeuf')309+310+ self.assertEquals(r.status_code, 200)311+ self.assertEquals(r.headers['content-type'], 'application/json')312+ self.assertEquals(r.url, service('post'))313+314+ rbody = json.loads(r.content)315+ # Body wasn't valid url encoded data, so the server returns None as316+ # "form" and the raw body as "data".317+ self.assertEquals(rbody.get('form'), None)318+ self.assertEquals(rbody.get('data'), 'fooaowpeuf')319+320+321+ def test_urlencoded_post_querystring(self):322+323+ for service in SERVICES:324+325+ r = requests.post(service('post'), params=dict(test='fooaowpeuf'))326+327+ self.assertEquals(r.status_code, 200)328+ self.assertEquals(r.headers['content-type'], 'application/json')329+ self.assertEquals(r.url, service('post?test=fooaowpeuf'))330+331+ rbody = json.loads(r.content)332+ self.assertEquals(rbody.get('form'), {}) # No form supplied333+ self.assertEquals(rbody.get('data'), '')334+335+336+ def test_nonurlencoded_post_querystring(self):337+338+ for service in SERVICES:339+340+ r = requests.post(service('post'), params='fooaowpeuf')341+342+ self.assertEquals(r.status_code, 200)343+ self.assertEquals(r.headers['content-type'], 'application/json')344+ self.assertEquals(r.url, service('post?fooaowpeuf'))345+346+ rbody = json.loads(r.content)347+ self.assertEquals(rbody.get('form'), {}) # No form supplied348+ self.assertEquals(rbody.get('data'), '')349+350+351+ def test_urlencoded_post_query_and_data(self):352+353+ for service in SERVICES:354+355+ r = requests.post(356+ service('post'),357+ params=dict(test='fooaowpeuf'),358+ data=dict(test2="foobar"))359+360+ self.assertEquals(r.status_code, 200)361+ self.assertEquals(r.headers['content-type'], 'application/json')362+ self.assertEquals(r.url, service('post?test=fooaowpeuf'))363+364+ rbody = json.loads(r.content)365+ self.assertEquals(rbody.get('form'), dict(test2='foobar'))366+ self.assertEquals(rbody.get('data'), '')367+368+369+ def test_nonurlencoded_post_query_and_data(self):370+371+ for service in SERVICES:372+373+ r = requests.post(service('post'),374+ params='fooaowpeuf', data="foobar")375+376+ self.assertEquals(r.status_code, 200)377+ self.assertEquals(r.headers['content-type'], 'application/json')378+ self.assertEquals(r.url, service('post?fooaowpeuf'))379+380+ rbody = json.loads(r.content)381+382+ self.assertEquals(rbody.get('form'), None)383+ self.assertEquals(rbody.get('data'), 'foobar')384+385+386+ def test_idna(self):387+ r = requests.get(u'http://➡.ws/httpbin')388+ assert 'httpbin' in r.url389+390+391+ def test_urlencoded_get_query_multivalued_param(self):392+393+ for service in SERVICES:394+395+ r = requests.get(service('get'), params=dict(test=['foo','baz']))396+ self.assertEquals(r.status_code, 200)397+ self.assertEquals(r.url, service('get?test=foo&test=baz'))398+399+400+ def test_urlencoded_post_querystring_multivalued(self):401+402+ for service in SERVICES:403+404+ r = requests.post(service('post'), params=dict(test=['foo','baz']))405+ self.assertEquals(r.status_code, 200)406+ self.assertEquals(r.headers['content-type'], 'application/json')407+ self.assertEquals(r.url, service('post?test=foo&test=baz'))408+409+ rbody = json.loads(r.content)410+ self.assertEquals(rbody.get('form'), {}) # No form supplied411+ self.assertEquals(rbody.get('data'), '')412+413+414+ def test_urlencoded_post_query_multivalued_and_data(self):415+416+ for service in SERVICES:417+418+ r = requests.post(419+ service('post'),420+ params=dict(test=['foo','baz']),421+ data=dict(test2="foobar",test3=['foo','baz']))422+423+ self.assertEquals(r.status_code, 200)424+ self.assertEquals(r.headers['content-type'], 'application/json')425+ self.assertEquals(r.url, service('post?test=foo&test=baz'))426+ rbody = json.loads(r.content)427+ self.assertEquals(rbody.get('form'), dict(test2='foobar',test3='foo'))428+ self.assertEquals(rbody.get('data'), '')429+430+431+ def test_redirect_history(self):432+433+ for service in SERVICES:434+435+ r = requests.get(service('redirect', '3'))436+ self.assertEquals(r.status_code, 200)437+ self.assertEquals(len(r.history), 3)438+439+440+ def test_relative_redirect_history(self):441+442+ for service in SERVICES:443+444+ r = requests.get(service('relative-redirect', '3'))445+ self.assertEquals(r.status_code, 200)446+ self.assertEquals(len(r.history), 3)447+448+449+ def test_session_HTTP_200_OK_GET(self):450+451+ s = Session()452+ r = s.get(httpbin('/'))453+ self.assertEqual(r.status_code, 200)454+455+456+ def test_session_HTTPS_200_OK_GET(self):457+458+ s = Session()459+ r = s.get(httpsbin('/'))460+ self.assertEqual(r.status_code, 200)461+462+463+ def test_session_persistent_headers(self):464+465+ heads = {'User-agent': 'Mozilla/5.0'}466+467+ s = Session()468+ s.headers = heads469+ # Make 2 requests from Session object, should send header both times470+ r1 = s.get(httpbin('user-agent'))471+472+ assert heads['User-agent'] in r1.content473+ r2 = s.get(httpbin('user-agent'))474+475+ assert heads['User-agent'] in r2.content476+ self.assertEqual(r2.status_code, 200)477+478+479+480+ def test_curl_HTTP_OK_GET(self):481+ curl_str = 'curl -L -X GET -H "Accept-Encoding:gzip" -H "User-Agent:python-requests.org" "http://httpbin.org//"'482+ r = requests.get(httpbin('/'))483+ self.assertEqual(curl_from_request(r.request), curl_str)484+485+486+ def test_curl_HTTP_OK_GET_WITH_PARAMS(self):487+ curl_str = 'curl -L -X GET -H "Accept-Encoding:gzip" -H "User-agent:Mozilla/5.0" "http://httpbin.org/user-agent"'488+489+ heads = {'User-agent': 'Mozilla/5.0'}490+ r = requests.get(httpbin('user-agent'), headers=heads)491+ self.assertEqual(curl_from_request(r.request), curl_str)492+493+494+ def test_curl_HTTP_OK_HEAD(self):495+ curl_str ='curl -L -I -H "Accept-Encoding:gzip" -H "User-Agent:python-requests.org" "http://httpbin.org//"'496+ r = requests.head(httpbin('/'))497+ self.assertEqual(curl_from_request(r.request), curl_str)498+499+500+ def test_curl_HTTP_OK_PATCH(self):501+ curl_str = 'curl -L -X PATCH -H "Accept-Encoding:gzip" -H "User-Agent:python-requests.org" "http://httpbin.org/patch"'502+ r = requests.patch(httpbin('patch'))503+ self.assertEqual(curl_from_request(r.request), curl_str)504+505+506+ def test_curl_AUTH_HTTPS_OK_GET(self):507+ curl_str = 'curl -L -u "user:pass" -X GET -H "Accept-Encoding:gzip" -H "User-Agent:python-requests.org" "https://httpbin.ep.io/basic-auth/user/pass"'508+ auth = ('user', 'pass')509+ r = requests.get(httpsbin('basic-auth', 'user', 'pass'), auth=auth)510+ self.assertEqual(curl_from_request(r.request), curl_str)511+512+513+ def test_curl_POSTBIN_GET_POST_FILES(self):514+ curl_str = 'curl -L -X POST -H "Accept-Encoding:gzip" -H "User-Agent:python-requests.org" -d "some=data" "http://httpbin.org/post"'515+ post = requests.post(httpbin('post'), data={'some': 'data'})516+ self.assertEqual(curl_from_request(post.request), curl_str)517+518+ curl_str = 'curl -L -X POST -H "Accept-Encoding:gzip" -H "User-Agent:python-requests.org" -F "some=@test_requests.py" "https://httpbin.ep.io/post"'519+ post2 = requests.post(httpsbin('post'), files={'some': open('test_requests.py')})520+ self.assertEqual(curl_from_request(post2.request), curl_str)521+522+ curl_str = 'curl -L -X POST -H "Accept-Encoding:gzip" -H "User-Agent:python-requests.org" -d \'[{"some": "json"}]\' "http://httpbin.org/post"'523+ post3 = requests.post(httpbin('post'), data='[{"some": "json"}]')524+ self.assertEqual(curl_from_request(post3.request), curl_str)525+526+527+if __name__ == '__main__':528+ unittest.main()