Skip to content
Myr

Merge pull request #887 from rvoicilas/develop

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Small changes to make the code more PEP8 compliant

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 2363243, 820dfb0 · Browse files · 11 files+30 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+30 added−22 removed

  • tests:+19 added−11 removed
  • other:+11 added−11 removed

11 files+30 added−22 removed

modified:requests/auth.py+1 added-1 removed
92 unmodified lines
93 # 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 lines
modified:requests/compat.py+1 added-1 removed
113 unmodified lines
114115 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 lines
234 """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 lines
278 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 conflict285286 if toReturn:
36 unmodified lines
323 discard=True,324 comment=None,325 comment_url=None,326 rest={'HttpOnly': None},327 rfc2109=False,328 )327 rfc2109=False,)328329 badargs = set(kwargs) - set(result)330 if badargs:331 err = 'create_cookie() got unexpected keyword arguments: %s'
26 unmodified lines
358 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 c364365366def cookiejar_from_dict(cookie_dict, cookiejar=None):
11 unmodified lines
modified:requests/hooks.py-1 removed
43 unmodified lines
44 _hook_data = hook(hook_data)45 if _hook_data is not None:46 hook_data = _hook_data474848 return hook_data
modified:requests/models.py+1 added-1 removed
109 unmodified lines
110111 # Dictionary mapping protocol to the URL of the proxy (e.g. {'http': 'foo.bar:3128'})112 self.proxies = dict(proxies or [])113114 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]117118 # If no proxies are given, allow configuration by environment variables
774 unmodified lines
modified:requests/utils.py+4 added-1 removed
376 unmodified lines
377 rv = decoder.decode('', final=True)378 if rv:379 yield rv380381382def 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_length388389390def get_unicode_from_response(r):391 """Returns the requested content back in unicode.392393 :param r: Response object to get unicode content from.
150 unmodified lines
544 '%s/%s' % (_implementation, _implementation_version),545 '%s/%s' % (platform.system(), platform.release()),546 ])547548549def parse_header_links(value):550 """Return a dict of parsed link headers proxies.551552 i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
28 unmodified lines
modified:tests/informal/test_leaked_connections.py+5 added-1 removed
2 unmodified lines
3it verifies that Requests does not leak connections when4the body of the request is not read.5"""67import gc, os, subprocess, requests, sys7import gc8import os9import requests10import subprocess11import sys121314def main():15 gc.disable()
16 unmodified lines
modified:tests/test_proxies.py+7 added-5 removed
1#!/usr/bin/env python2# -*- coding: utf-8 -*-34import sys, os, unittest4import os5import sys6import unittest78# Path hack.9sys.path.insert(0, os.path.abspath('..'))10import requests
4 unmodified lines
1516 smoke_url = "https://github.com"1718 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)2223 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)2728if __name__ == '__main__':29 unittest.main()
modified:tests/test_requests_ext.py+2 added-1 removed
1#!/usr/bin/env python2# -*- coding: utf-8 -*-34# Path hack.5import sys, os5import os6import sys7sys.path.insert(0, os.path.abspath('..'))89import unittest10
114 unmodified lines
modified:tests/test_requests_https.py+2 added-2 removed
1#!/usr/bin/env python2# -*- coding: utf-8 -*-34import sys, os5import json4import os5import sys6import unittest78# Path hack.9sys.path.insert(0, os.path.abspath('..'))
23 unmodified lines
modified:tests/test_requests.py+3 added-2 removed
49 unmodified lines
50 # c = envoy.connect('httpbin %s' % (PORT))51 # time.sleep(1)52 _httpbin = True535455class TestBaseMixin(object):5657 def assertCookieHas(self, cookie, **kwargs):58 """Assert that a cookie has various specified properties."""
1 unmodified line
60 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)636465class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):66 """Requests test cases."""6768 def test_entry_points(self):
835 unmodified lines
904905 def test_connection_error_with_safe_mode(self):906 config = {'safe_mode': True}907 r = get('http://localhost:1/nope', allow_redirects=False, config=config)906 assert r.content == None908 assert r.content is None909910 # def test_invalid_content(self):911 # # WARNING: if you're using a terrible DNS provider (comcast),912 # # this will fail.
126 unmodified lines
1039 s = requests.session()1040 s.config['danger_mode'] = True1041 s.get(httpbin('redirect', '4'))104210411043 def test_empty_response(self):1044 r = requests.get(httpbin('status', '404'))1045 r.text1046
138 unmodified lines