Merge remote-tracking branch 'origin/develop' into develop
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 · parents b73426a, aa08f33 · Browse files · 17 files·+60 added−40 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
17 files+60 added−40 removed
- tests:+35 added−16 removed
- other:+25 added−24 removed
Provenance
- Commit
a74c6c6- Tree
5b9b323- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent 1
b73426a- Parent 2
aa08f33
17 files changed+60 added−40 removed
modified:docs/_themes/README.rst+5 added-5 removed
9 unmodified lines10 you can also use git submodules to check out the contents there.11 12 2. add this to your conf.py: ::13 14- sys.path.append(os.path.abspath('_themes'))15- html_theme_path = ['_themes']16- html_theme = 'flask'14+ sys.path.append(os.path.abspath('_themes'))15+ html_theme_path = ['_themes']16+ html_theme = 'flask'17 18 The following themes exist:19 20 **kr**21- the standard flask documentation theme for large projects21+ the standard flask documentation theme for large projects22 23 **kr_small**24- small one-page theme. Intended to be used by very small addon libraries.24+ small one-page theme. Intended to be used by very small addon libraries.25 modified:docs/community/support.rst+1 added-1 removed
32 unmodified lines33 34 The official Freenode channel for Requests is35 `#python-requests <irc://irc.freenode.net/python-requests>`_36 37-I'm also available as **kennethreitz** on Freenode.37+I'm also available as **kennethreitz** on Freenode.modified:docs/dev/authors.rst+1 added-1 removed
1 Authors2 =======3 4 5-.. include:: ../../AUTHORS.rst5+.. include:: ../../AUTHORS.rstmodified:docs/user/install.rst+3 added-3 removed
23 unmodified lines24 25 Cheeseshop Mirror26 -----------------27 28-If the Cheeseshop is down, you can also install Requests from Kenneth Reitz's29-personal `Cheeseshop mirror <http://pip.kennethreitz.com/>`_::28+If the Cheeseshop is down, you can also install Requests from one of the29+mirrors. `Crate.io <http://crate.io>`_ is one of them::30 31- $ pip install -i http://pip.kennethreitz.com/simple requests31+ $ pip install -i http://simple.crate.io/ requests32 33 34 Get the Code35 ------------21 unmodified linesmodified:docs/conf.py+1 added-1 removed
239 unmodified lines240 texinfo_appendices = []241 242 sys.path.append(os.path.abspath('_themes'))243 html_theme_path = ['_themes']244-html_theme = 'kr'244+html_theme = 'kr'modified:requests/auth.py+1 added-1 removed
92 unmodified lines93 # be empty (cant add paras to body if multipart) and we wish94 # to preserve body.95 r.url, r.headers, _ = self.client.sign(96 unicode(r.full_url), unicode(r.method), None, r.headers)97- elif decoded_body != None and contenttype in (CONTENT_TYPE_FORM_URLENCODED, ''):97+ elif decoded_body is not None and contenttype in (CONTENT_TYPE_FORM_URLENCODED, ''):98 # Normal signing99 if not contenttype:100 r.headers['Content-Type'] = CONTENT_TYPE_FORM_URLENCODED101 r.url, r.headers, r.data = self.client.sign(281 unmodified linesmodified:requests/compat.py+1 added-1 removed
113 unmodified lines114 115 builtin_str = str116 str = str117 bytes = bytes118- basestring = (str,bytes)118+ basestring = (str, bytes)119 numeric_types = (int, float)modified:requests/cookies.py+4 added-6 removed
233 unmodified lines234 """Takes as an argument an optional domain and path and returns a plain old235 Python dict of name-value pairs of cookies that meet the requirements."""236 dictionary = {}237 for cookie in iter(self):238- if (domain == None or cookie.domain == domain) and (path == None238+ if (domain is None or cookie.domain == domain) and (path is None239 or cookie.path == path):240 dictionary[cookie.name] = cookie.value241 return dictionary242 35 unmodified lines278 for cookie in iter(self):279 if cookie.name == name:280 if domain is None or cookie.domain == domain:281 if path is None or cookie.path == path:282- if toReturn != None: # if there are multiple cookies that meet passed in criteria282+ if toReturn is not None: # if there are multiple cookies that meet passed in criteria283 raise CookieConflictError('There are multiple cookies with name, %r' % (name))284 toReturn = cookie.value # we will eventually return this as long as no cookie conflict285 286 if toReturn:36 unmodified lines323 discard=True,324 comment=None,325 comment_url=None,326 rest={'HttpOnly': None},327- rfc2109=False,328- )327+ rfc2109=False,)328 329 badargs = set(kwargs) - set(result)330 if badargs:331 err = 'create_cookie() got unexpected keyword arguments: %s'26 unmodified lines358 discard=False,359 comment=morsel['comment'],360 comment_url=bool(morsel['comment']),361 rest={'HttpOnly': morsel['httponly']},363- rfc2109=False,364- )362+ rfc2109=False,)363 return c364 365 366 def cookiejar_from_dict(cookie_dict, cookiejar=None):11 unmodified linesmodified:requests/hooks.py-1 removed
43 unmodified lines44 _hook_data = hook(hook_data)45 if _hook_data is not None:46 hook_data = _hook_data47 48-48 return hook_datamodified:requests/models.py+3 added-3 removed
109 unmodified lines110 111 # Dictionary mapping protocol to the URL of the proxy (e.g. {'http': 'foo.bar:3128'})112 self.proxies = dict(proxies or [])113 114- for proxy_type,uri_ref in list(self.proxies.items()):114+ for proxy_type, uri_ref in list(self.proxies.items()):115 if not uri_ref:116 del self.proxies[proxy_type]117 118 # If no proxies are given, allow configuration by environment variables240 unmodified lines359 360 for field, val in fields:361 if isinstance(val, list):362 for v in val:363- new_fields.append((field, str(v)))363+ new_fields.append((field, builtin_str(v)))364 else:365- new_fields.append((field, str(val)))365+ new_fields.append((field, builtin_str(val)))366 367 for (k, v) in files:368 # support for explicit filename369 if isinstance(v, (tuple, list)):523 unmodified linesmodified:requests/utils.py+4 added-1 removed
376 unmodified lines377 rv = decoder.decode('', final=True)378 if rv:379 yield rv380 381+382 def iter_slices(string, slice_length):383 """Iterate over slices of a string."""384 pos = 0385 while pos < len(string):385- yield string[pos:pos+slice_length]386+ yield string[pos:pos + slice_length]387 pos += slice_length388 389+390 def get_unicode_from_response(r):391 """Returns the requested content back in unicode.392 393 :param r: Response object to get unicode content from.150 unmodified lines544 '%s/%s' % (_implementation, _implementation_version),545 '%s/%s' % (platform.system(), platform.release()),546 ])547 548+549 def parse_header_links(value):550 """Return a dict of parsed link headers proxies.551 552 i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"28 unmodified linesmodified:tests/informal/test_leaked_connections.py+5 added-1 removed
2 unmodified lines3 it verifies that Requests does not leak connections when4 the body of the request is not read.5 """6 7-import gc, os, subprocess, requests, sys7+import gc8+import os9+import requests10+import subprocess11+import sys12 13 14 def main():15 gc.disable()16 unmodified linesmodified:tests/test_proxies.py+7 added-5 removed
1 #!/usr/bin/env python2 # -*- coding: utf-8 -*-3 4-import sys, os, unittest4+import os5+import sys6+import unittest7 8 # Path hack.9 sys.path.insert(0, os.path.abspath('..'))10 import requests4 unmodified lines15 16 smoke_url = "https://github.com"17 18 def test_empty_https_proxy(self):17- proxy = {"https" : "" }18- result = requests.get(self.smoke_url, verify=False, proxies = proxy)19+ proxy = {"https": ""}20+ result = requests.get(self.smoke_url, verify=False, proxies=proxy)21 self.assertEqual(result.status_code, 200)22 23 def test_empty_http_proxy(self):22- proxy = {"http" : "" }23- result = requests.get(self.smoke_url, proxies = proxy)24+ proxy = {"http": ""}25+ result = requests.get(self.smoke_url, proxies=proxy)26 self.assertEqual(result.status_code, 200)27 28 if __name__ == '__main__':29 unittest.main()modified:tests/test_requests_ext.py+2 added-1 removed
1 #!/usr/bin/env python2 # -*- coding: utf-8 -*-3 4 # Path hack.5-import sys, os5+import os6+import sys7 sys.path.insert(0, os.path.abspath('..'))8 9 import unittest10 114 unmodified linesmodified:tests/test_requests_https.py+2 added-2 removed
1 #!/usr/bin/env python2 # -*- coding: utf-8 -*-3 4-import sys, os5-import json4+import os5+import sys6 import unittest7 8 # Path hack.9 sys.path.insert(0, os.path.abspath('..'))23 unmodified linesmodified:tests/test_requests.py+19 added-7 removed
49 unmodified lines50 # c = envoy.connect('httpbin %s' % (PORT))51 # time.sleep(1)52 _httpbin = True53 54+55 class TestBaseMixin(object):56 57 def assertCookieHas(self, cookie, **kwargs):58 """Assert that a cookie has various specified properties."""1 unmodified line60 cookie_attr = getattr(cookie, attr)61 message = 'Failed comparison for %s: %s != %s' % (attr, cookie_attr, expected_value)62 self.assertEqual(cookie_attr, expected_value, message)63 64+65 class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):66 """Requests test cases."""67 68 def test_entry_points(self):268 unmodified lines337 for service in SERVICES:338 339 with open(__file__) as f:340 url = service('post')339- post1 = post(url,340- files={'some': f},341- data={'some': 'data'})341+ post1 = post(url, data={'some': 'data'}, files={'some': f})342 post2 = post(url, data={'some': 'data'}, files=[('some', f)])343- post3 = post(url, data=[('some', 'data')],344- files=[('some', f)])343+ post3 = post(url, data=[('some', 'data')], files=[('some', f)])344 345 self.assertEqual(post1.status_code, 200)346 self.assertEqual(post2.status_code, 200)347 self.assertEqual(post3.status_code, 200)348 349+ def test_POSTBIN_GET_POST_FILES_WITH_CJK_PARAMS(self):350+351+ for service in SERVICES:352+353+ with open(__file__) as f:354+ url = service('post')355+ post1 = post(url, data={'some': '中文'}, files={'some': f})356+ post2 = post(url, data={'some': '日本語'}, files=[('some', f)])357+ post3 = post(url, data=[('some', '한국의')], files=[('some', f)])358+359+ self.assertEqual(post1.status_code, 200)360+ self.assertEqual(post2.status_code, 200)361+ self.assertEqual(post3.status_code, 200)362+363 def test_POSTBIN_GET_POST_FILES_WITH_HEADERS(self):364 365 for service in SERVICES:366 548 unmodified lines915 916 def test_connection_error_with_safe_mode(self):917 config = {'safe_mode': True}918 r = get('http://localhost:1/nope', allow_redirects=False, config=config)906- assert r.content == None919+ assert r.content is None920 921 # def test_invalid_content(self):922 # # WARNING: if you're using a terrible DNS provider (comcast),923 # # this will fail.126 unmodified lines1050 s = requests.session()1051 s.config['danger_mode'] = True1052 s.get(httpbin('redirect', '4'))1053 1041-1054 def test_empty_response(self):1055 r = requests.get(httpbin('status', '404'))1056 r.text1057 138 unmodified linesmodified:AUTHORS.rst+1 added
112 unmodified lines113 - Jakub Roztocil <jakub@roztocil.name>114 - Ian Cordasco <graffatcolmingov@gmail.com> @sigmavirus24115 - Rhys Elsmore116 - André Graf (dergraf)117+- Stephen Zhuang (everbird)