From 15a3869006fa68d7ad34bc315842f2ca5b537311 Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Tue, 19 Jul 2016 14:51:14 -0600 Subject: [PATCH 1/2] making module docstrings and coding comments consistent --- requests/__init__.py | 1 - requests/api.py | 1 - requests/certs.py | 4 ++-- requests/compat.py | 6 +++++- requests/cookies.py | 3 +++ requests/exceptions.py | 1 - requests/hooks.py | 1 - requests/sessions.py | 1 - requests/structures.py | 1 - requests/utils.py | 1 - tests/__init__.py | 2 +- tests/compat.py | 3 ++- tests/conftest.py | 3 ++- tests/test_hooks.py | 3 ++- tests/test_lowlevel.py | 2 ++ tests/test_structures.py | 3 ++- tests/test_testserver.py | 2 ++ tests/test_utils.py | 3 ++- tests/testserver/server.py | 2 ++ tests/utils.py | 2 ++ 20 files changed, 29 insertions(+), 16 deletions(-) diff --git a/requests/__init__.py b/requests/__init__.py index 9a66ee1b..aea1fbf2 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -38,7 +38,6 @@ is at . :copyright: (c) 2016 by Kenneth Reitz. :license: Apache 2.0, see LICENSE for more details. - """ __title__ = 'requests' diff --git a/requests/api.py b/requests/api.py index c2068d0e..580b3f35 100644 --- a/requests/api.py +++ b/requests/api.py @@ -8,7 +8,6 @@ This module implements the Requests API. :copyright: (c) 2012 by Kenneth Reitz. :license: Apache2, see LICENSE for more details. - """ from . import sessions diff --git a/requests/certs.py b/requests/certs.py index 07e64750..f922b99d 100644 --- a/requests/certs.py +++ b/requests/certs.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- """ -certs.py -~~~~~~~~ +requests.certs +~~~~~~~~~~~~~~ This module returns the preferred default CA certificate bundle. diff --git a/requests/compat.py b/requests/compat.py index 70edff78..eb6530d6 100644 --- a/requests/compat.py +++ b/requests/compat.py @@ -1,7 +1,11 @@ # -*- coding: utf-8 -*- """ -pythoncompat +requests.compat +~~~~~~~~~~~~~~~ + +This module handles import compatibility issues between Python 2 and +Python 3. """ from .packages import chardet diff --git a/requests/cookies.py b/requests/cookies.py index eee5168f..255d92db 100644 --- a/requests/cookies.py +++ b/requests/cookies.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- """ +requests.cookies +~~~~~~~~~~~~~~~~ + Compatibility code to be able to use `cookielib.CookieJar` with requests. requests.utils imports from here, so be careful with imports. diff --git a/requests/exceptions.py b/requests/exceptions.py index 3f056492..91de8bbc 100644 --- a/requests/exceptions.py +++ b/requests/exceptions.py @@ -5,7 +5,6 @@ requests.exceptions ~~~~~~~~~~~~~~~~~~~ This module contains the set of Requests' exceptions. - """ from .packages.urllib3.exceptions import HTTPError as BaseHTTPError diff --git a/requests/hooks.py b/requests/hooks.py index 9da94366..70d83a4b 100644 --- a/requests/hooks.py +++ b/requests/hooks.py @@ -10,7 +10,6 @@ Available hooks: ``response``: The response generated from a Request. - """ HOOKS = ['response'] diff --git a/requests/sessions.py b/requests/sessions.py index 3f405ba9..d2bae11f 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -6,7 +6,6 @@ requests.session This module provides a Session object to manage and persist settings across requests (cookies, auth, proxies). - """ import os from collections import Mapping diff --git a/requests/structures.py b/requests/structures.py index 991056e4..c4c78b2b 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -5,7 +5,6 @@ requests.structures ~~~~~~~~~~~~~~~~~~~ Data structures that power Requests. - """ import collections diff --git a/requests/utils.py b/requests/utils.py index 397a655e..16b51b63 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -6,7 +6,6 @@ requests.utils This module provides utility functions that are used within Requests that are also useful for external consumption. - """ import cgi diff --git a/tests/__init__.py b/tests/__init__.py index 3e222031..1b7182a5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- """Requests test package initialisation.""" diff --git a/tests/compat.py b/tests/compat.py index a26bd9f4..f68e8014 100644 --- a/tests/compat.py +++ b/tests/compat.py @@ -1,4 +1,5 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- + from requests.compat import is_py3 diff --git a/tests/conftest.py b/tests/conftest.py index af20e54d..cd64a765 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- + import pytest from requests.compat import urljoin diff --git a/tests/test_hooks.py b/tests/test_hooks.py index e2b174d8..014b4391 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -1,4 +1,5 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- + import pytest from requests import hooks diff --git a/tests/test_lowlevel.py b/tests/test_lowlevel.py index f3dd1b11..f6eaa93a 100644 --- a/tests/test_lowlevel.py +++ b/tests/test_lowlevel.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import os import pytest import threading diff --git a/tests/test_structures.py b/tests/test_structures.py index 1c332bb2..623f2b1e 100644 --- a/tests/test_structures.py +++ b/tests/test_structures.py @@ -1,4 +1,5 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- + import pytest from requests.structures import CaseInsensitiveDict, LookupDict diff --git a/tests/test_testserver.py b/tests/test_testserver.py index 9a35460e..b90a9db1 100644 --- a/tests/test_testserver.py +++ b/tests/test_testserver.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import threading import socket import time diff --git a/tests/test_utils.py b/tests/test_utils.py index ab5c2e37..6f22f659 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,5 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- + from io import BytesIO import pytest diff --git a/tests/testserver/server.py b/tests/testserver/server.py index 7a92c87d..93b6522a 100644 --- a/tests/testserver/server.py +++ b/tests/testserver/server.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import threading import socket import select diff --git a/tests/utils.py b/tests/utils.py index 6cb75bfb..9b797fd4 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import contextlib import os From b7809acb473cf084b467b0ec0a524c50bcbe225f Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Wed, 20 Jul 2016 11:43:47 -0600 Subject: [PATCH 2/2] making class and function docstrings consistent --- requests/cookies.py | 89 ++++++++++++++++++++++++++++------------ requests/exceptions.py | 11 ++--- requests/models.py | 7 +--- requests/sessions.py | 18 ++++---- requests/structures.py | 4 +- requests/utils.py | 33 +++++++-------- tests/test_requests.py | 9 ++-- tests/test_structures.py | 8 +--- tests/test_utils.py | 14 +++---- 9 files changed, 101 insertions(+), 92 deletions(-) diff --git a/requests/cookies.py b/requests/cookies.py index 255d92db..19d63d88 100644 --- a/requests/cookies.py +++ b/requests/cookies.py @@ -161,7 +161,8 @@ def remove_cookie_by_name(cookiejar, name, domain=None, path=None): class CookieConflictError(RuntimeError): """There are two cookies that meet the criteria specified in the cookie jar. - Use .get and .set and include domain and path args in order to be more specific.""" + Use .get and .set and include domain and path args in order to be more specific. + """ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): @@ -186,7 +187,8 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): order to resolve naming collisions from using one cookie jar over multiple domains. - .. warning:: operation is O(n), not O(1).""" + .. warning:: operation is O(n), not O(1). + """ try: return self._find_no_duplicates(name, domain, path) except KeyError: @@ -195,7 +197,8 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): def set(self, name, value, **kwargs): """Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over - multiple domains.""" + multiple domains. + """ # support client code that unsets cookies by assignment of a None value: if value is None: remove_cookie_by_name(self, name, domain=kwargs.get('domain'), path=kwargs.get('path')) @@ -210,37 +213,54 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): def iterkeys(self): """Dict-like iterkeys() that returns an iterator of names of cookies - from the jar. See itervalues() and iteritems().""" + from the jar. + + .. seealso:: itervalues() and iteritems(). + """ for cookie in iter(self): yield cookie.name def keys(self): """Dict-like keys() that returns a list of names of cookies from the - jar. See values() and items().""" + jar. + + .. seealso:: values() and items(). + """ return list(self.iterkeys()) def itervalues(self): """Dict-like itervalues() that returns an iterator of values of cookies - from the jar. See iterkeys() and iteritems().""" + from the jar. + + .. seealso:: iterkeys() and iteritems(). + """ for cookie in iter(self): yield cookie.value def values(self): """Dict-like values() that returns a list of values of cookies from the - jar. See keys() and items().""" + jar. + + .. seealso:: keys() and items(). + """ return list(self.itervalues()) def iteritems(self): """Dict-like iteritems() that returns an iterator of name-value tuples - from the jar. See iterkeys() and itervalues().""" + from the jar. + + .. seealso:: iterkeys() and itervalues(). + """ for cookie in iter(self): yield cookie.name, cookie.value def items(self): """Dict-like items() that returns a list of name-value tuples from the - jar. See keys() and values(). Allows client-code to call - ``dict(RequestsCookieJar)`` and get a vanilla python dict of key value - pairs.""" + jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a + vanilla python dict of key value pairs. + + .. seealso:: keys() and values(). + """ return list(self.iteritems()) def list_domains(self): @@ -261,7 +281,8 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): def multiple_domains(self): """Returns True if there are multiple domains in the jar. - Returns False otherwise.""" + Returns False otherwise. + """ domains = [] for cookie in iter(self): if cookie.domain is not None and cookie.domain in domains: @@ -272,7 +293,8 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): def get_dict(self, domain=None, path=None): """Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the - requirements.""" + requirements. + """ dictionary = {} for cookie in iter(self): if (domain is None or cookie.domain == domain) and (path is None @@ -291,20 +313,21 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): exception if there are more than one cookie with name. In that case, use the more explicit get() method instead. - .. warning:: operation is O(n), not O(1).""" - + .. warning:: operation is O(n), not O(1). + """ return self._find_no_duplicates(name) def __setitem__(self, name, value): """Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that - case, use the more explicit set() method instead.""" - + case, use the more explicit set() method instead. + """ self.set(name, value) def __delitem__(self, name): """Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s - ``remove_cookie_by_name()``.""" + ``remove_cookie_by_name()``. + """ remove_cookie_by_name(self, name) def set_cookie(self, cookie, *args, **kwargs): @@ -321,11 +344,17 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): super(RequestsCookieJar, self).update(other) def _find(self, name, domain=None, path=None): - """Requests uses this method internally to get cookie values. Takes as - args name and optional domain and path. Returns a cookie.value. If - there are conflicting cookies, _find arbitrarily chooses one. See - _find_no_duplicates if you want an exception thrown if there are - conflicting cookies.""" + """Requests uses this method internally to get cookie values. + + If there are conflicting cookies, _find arbitrarily chooses one. + See _find_no_duplicates if you want an exception thrown if there are + conflicting cookies. + + :param name: a string containing name of cookie + :param domain: (optional) string containing domain of cookie + :param path: (optional) string containing path of cookie + :return: cookie.value + """ for cookie in iter(self): if cookie.name == name: if domain is None or cookie.domain == domain: @@ -336,10 +365,16 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): def _find_no_duplicates(self, name, domain=None, path=None): """Both ``__get_item__`` and ``get`` call this function: it's never - used elsewhere in Requests. Takes as args name and optional domain and - path. Returns a cookie.value. Throws KeyError if cookie is not found - and CookieConflictError if there are multiple cookies that match name - and optionally domain and path.""" + used elsewhere in Requests. + + :param name: a string containing name of cookie + :param domain: (optional) string containing domain of cookie + :param path: (optional) string containing path of cookie + :raises KeyError: if cookie is not found + :raises CookieConflictError: if there are multiple cookies + that match name and optionally domain and path + :return: cookie.value + """ toReturn = None for cookie in iter(self): if cookie.name == name: diff --git a/requests/exceptions.py b/requests/exceptions.py index 91de8bbc..b89e0cc6 100644 --- a/requests/exceptions.py +++ b/requests/exceptions.py @@ -11,12 +11,11 @@ from .packages.urllib3.exceptions import HTTPError as BaseHTTPError class RequestException(IOError): """There was an ambiguous exception that occurred while handling your - request.""" + request. + """ def __init__(self, *args, **kwargs): - """ - Initialize RequestException with `request` and `response` objects. - """ + """Initialize RequestException with `request` and `response` objects.""" response = kwargs.pop('response', None) self.response = response self.request = kwargs.pop('request', None) @@ -111,7 +110,5 @@ class RequestsWarning(Warning): class FileModeWarning(RequestsWarning, DeprecationWarning): - """ - A file was opened in text mode, but Requests determined its binary length. - """ + """A file was opened in text mode, but Requests determined its binary length.""" pass diff --git a/requests/models.py b/requests/models.py index d9bcfc82..e372e03b 100644 --- a/requests/models.py +++ b/requests/models.py @@ -108,7 +108,6 @@ class RequestEncodingMixin(object): if parameters are supplied as a dict. The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype) or 4-tuples (filename, fileobj, contentype, custom_headers). - """ if (not files): raise ValueError("Files must be provided.") @@ -207,7 +206,6 @@ class Request(RequestHooksMixin): >>> req = requests.Request('GET', 'http://httpbin.org/get') >>> req.prepare() - """ def __init__(self, method=None, url=None, headers=None, files=None, data=None, params=None, auth=None, cookies=None, hooks=None, json=None): @@ -270,7 +268,6 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): >>> s = requests.Session() >>> s.send(r) - """ def __init__(self): @@ -516,8 +513,8 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): can only be called once for the life of the :class:`PreparedRequest ` object. Any subsequent calls to ``prepare_cookies`` will have no actual effect, unless the "Cookie" - header is removed beforehand.""" - + header is removed beforehand. + """ if isinstance(cookies, cookielib.CookieJar): self._cookies = cookies else: diff --git a/requests/sessions.py b/requests/sessions.py index d2bae11f..119eff48 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -39,9 +39,8 @@ REDIRECT_CACHE_SIZE = 1000 def merge_setting(request_setting, session_setting, dict_class=OrderedDict): - """ - Determines appropriate setting for a given request, taking into account the - explicit setting on that request, and the setting in the session. If a + """Determines appropriate setting for a given request, taking into account + the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` """ @@ -71,8 +70,7 @@ def merge_setting(request_setting, session_setting, dict_class=OrderedDict): def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict): - """ - Properly merges both requests and session hooks. + """Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. @@ -184,8 +182,7 @@ class SessionRedirectMixin(object): yield resp def rebuild_auth(self, prepared_request, response): - """ - When being redirected we may want to strip authentication from the + """When being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss. """ @@ -209,8 +206,7 @@ class SessionRedirectMixin(object): return def rebuild_proxies(self, prepared_request, proxies): - """ - This method re-evaluates the proxy configuration by considering the + """This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous @@ -661,8 +657,8 @@ class Session(SessionRedirectMixin): def mount(self, prefix, adapter): """Registers a connection adapter to a prefix. - Adapters are sorted in descending order by key length.""" - + Adapters are sorted in descending order by key length. + """ self.adapters[prefix] = adapter keys_to_move = [k for k in self.adapters if len(k) < len(prefix)] diff --git a/requests/structures.py b/requests/structures.py index c4c78b2b..85231080 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -13,8 +13,7 @@ from .compat import OrderedDict class CaseInsensitiveDict(collections.MutableMapping): - """ - A case-insensitive ``dict``-like object. + """A case-insensitive ``dict``-like object. Implements all methods and operations of ``collections.MutableMapping`` as well as dict's ``copy``. Also @@ -38,7 +37,6 @@ class CaseInsensitiveDict(collections.MutableMapping): If the constructor, ``.update``, or equality comparison operations are given keys that have equal ``.lower()``s, the behavior is undefined. - """ def __init__(self, data=None, **kwargs): self._store = OrderedDict() diff --git a/requests/utils.py b/requests/utils.py index 16b51b63..998dd0e6 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -399,7 +399,6 @@ def get_unicode_from_response(r): 1. charset from content-type 2. fall back and replace all unicode characters - """ warnings.warn(( 'In requests 3.0, get_unicode_from_response will be removed. For ' @@ -474,8 +473,8 @@ def requote_uri(uri): def address_in_network(ip, net): - """ - This function allows you to check if on IP belongs to a network subnet + """This function allows you to check if on IP belongs to a network subnet + Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24 returns False if ip = 192.168.1.1 and net = 192.168.100.0/24 """ @@ -487,8 +486,8 @@ def address_in_network(ip, net): def dotted_netmask(mask): - """ - Converts mask from /xx format to xxx.xxx.xxx.xxx + """Converts mask from /xx format to xxx.xxx.xxx.xxx + Example: if mask is 24 function returns 255.255.255.0 """ bits = 0xffffffff ^ (1 << 32 - mask) - 1 @@ -524,9 +523,7 @@ def is_valid_cidr(string_network): def should_bypass_proxies(url): - """ - Returns whether we should bypass proxies or not. - """ + """Returns whether we should bypass proxies or not.""" get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper()) # First check whether no_proxy is defined. If it is, check that the URL @@ -627,7 +624,6 @@ def parse_header_links(value): """Return a dict of parsed link headers proxies. i.e. Link: ; rel=front; type="image/jpeg",; rel=back;type="image/jpeg" - """ links = [] @@ -692,7 +688,8 @@ def guess_json_utf(data): def prepend_scheme_if_needed(url, new_scheme): """Given a URL that may or may not have a scheme, prepend the given scheme. - Does not replace a present scheme with the one provided as an argument.""" + Does not replace a present scheme with the one provided as an argument. + """ scheme, netloc, path, params, query, fragment = urlparse(url, new_scheme) # urlparse is a finicky beast, and sometimes decides that there isn't a @@ -706,7 +703,8 @@ def prepend_scheme_if_needed(url, new_scheme): def get_auth_from_url(url): """Given a url with authentication components, extract them into a tuple of - username,password.""" + username,password. + """ parsed = urlparse(url) try: @@ -718,10 +716,9 @@ def get_auth_from_url(url): def to_native_string(string, encoding='ascii'): - """ - Given a string object, regardless of type, returns a representation of that - string in the native string type, encoding and decoding where necessary. - This assumes ASCII unless told otherwise. + """Given a string object, regardless of type, returns a representation of + that string in the native string type, encoding and decoding where + necessary. This assumes ASCII unless told otherwise. """ if isinstance(string, builtin_str): out = string @@ -738,7 +735,7 @@ _CLEAN_HEADER_REGEX_BYTE = re.compile(b'^\\S[^\\r\\n]*$|^$') _CLEAN_HEADER_REGEX_STR = re.compile(r'^\S[^\r\n]*$|^$') def check_header_validity(header): - """Verifies that header value is a string which doesn't contain + """Verifies that header value is a string which doesn't contain leading whitespace or return characters. This prevents unintended header injection. @@ -758,9 +755,7 @@ def check_header_validity(header): "not %s" % (value, type(value))) def urldefragauth(url): - """ - Given a url remove the fragment and the authentication part - """ + """Given a url remove the fragment and the authentication part""" scheme, netloc, path, params, query, fragment = urlparse(url) # see func:`prepend_scheme_if_needed` diff --git a/tests/test_requests.py b/tests/test_requests.py index 73616272..6925db43 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -957,8 +957,7 @@ class TestRequests: io.close() def test_response_decode_unicode(self): - """ - When called with decode_unicode, Response.iter_content should always + """When called with decode_unicode, Response.iter_content should always return unicode. """ r = requests.Response() @@ -1049,9 +1048,7 @@ class TestRequests: assert r.status_code == 200 def test_fixes_1329(self, httpbin): - """ - Ensure that header updates are done case-insensitively. - """ + """Ensure that header updates are done case-insensitively.""" s = requests.Session() s.headers.update({'ACCEPT': 'BOGUS'}) s.headers.update({'accept': 'application/json'}) @@ -1580,7 +1577,7 @@ class TestTimeout: assert error_text in str(e) def test_none_timeout(self, httpbin): - """ Check that you can set None as a valid timeout value. + """Check that you can set None as a valid timeout value. To actually test this behavior, we'd want to check that setting the timeout to None actually lets the request block past the system default diff --git a/tests/test_structures.py b/tests/test_structures.py index 623f2b1e..e4d2459f 100644 --- a/tests/test_structures.py +++ b/tests/test_structures.py @@ -9,9 +9,7 @@ class TestCaseInsensitiveDict: @pytest.fixture(autouse=True) def setup(self): - """ - CaseInsensitiveDict instance with "Accept" header. - """ + """CaseInsensitiveDict instance with "Accept" header.""" self.case_insensitive_dict = CaseInsensitiveDict() self.case_insensitive_dict['Accept'] = 'application/json' @@ -55,9 +53,7 @@ class TestLookupDict: @pytest.fixture(autouse=True) def setup(self): - """ - LookupDict instance with "bad_gateway" attribute. - """ + """LookupDict instance with "bad_gateway" attribute.""" self.lookup_dict = LookupDict('test') self.lookup_dict.bad_gateway = 502 diff --git a/tests/test_utils.py b/tests/test_utils.py index 6f22f659..b78c7359 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -41,9 +41,7 @@ class TestSuperLen: @pytest.mark.parametrize('error', [IOError, OSError]) def test_super_len_handles_files_raising_weird_errors_in_tell(self, error): - """ - If tell() raises errors, assume the cursor is at position zero. - """ + """If tell() raises errors, assume the cursor is at position zero.""" class BoomFile(object): def __len__(self): return 5 @@ -105,7 +103,8 @@ class TestUnquoteHeaderValue: class TestGetEnvironProxies: """Ensures that IP addresses are correctly matches with ranges - in no_proxy variable.""" + in no_proxy variable. + """ @pytest.fixture(autouse=True, params=['no_proxy', 'NO_PROXY']) def no_proxy(self, request, monkeypatch): @@ -289,8 +288,7 @@ def test_get_auth_from_url(url, auth): ), )) def test_requote_uri_with_unquoted_percents(uri, expected): - """See: https://github.com/kennethreitz/requests/issues/2356 - """ + """See: https://github.com/kennethreitz/requests/issues/2356""" assert requote_uri(uri) == expected @@ -460,8 +458,8 @@ def test_urldefragauth(url, expected): ('http://google.com:5000/v1.0/', False), )) def test_should_bypass_proxies(url, expected, monkeypatch): - """ - Tests for function should_bypass_proxies to check if proxy can be bypassed or not + """Tests for function should_bypass_proxies to check if proxy + can be bypassed or not """ monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1') monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')