From 8a20ff549efc9d6ada5695c7e32f03663340130d Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Thu, 20 Apr 2017 15:24:47 +0200 Subject: Fix pylint warnings in decorators.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie6c53feb97053248c909d641753b44b5f51c8719 Signed-off-by: Cédric Ollivier --- functest/utils/decorators.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'functest') diff --git a/functest/utils/decorators.py b/functest/utils/decorators.py index 2ca31066..46ffe35d 100644 --- a/functest/utils/decorators.py +++ b/functest/utils/decorators.py @@ -1,38 +1,42 @@ #!/usr/bin/env python +# pylint: disable=missing-docstring + import errno -import mock import os -import requests.sessions import urlparse +import mock +import requests.sessions + def can_dump_request_to_file(method): def dump_preparedrequest(request, **kwargs): + # pylint: disable=unused-argument parseresult = urlparse.urlparse(request.url) if parseresult.scheme == "file": try: dirname = os.path.dirname(parseresult.path) os.makedirs(dirname) - except OSError as e: - if e.errno != errno.EEXIST: + except OSError as ex: + if ex.errno != errno.EEXIST: raise - with open(parseresult.path, 'a') as f: + with open(parseresult.path, 'a') as dumpfile: headers = "" for key in request.headers: headers += key + " " + request.headers[key] + "\n" message = "{} {}\n{}\n{}\n\n\n".format( request.method, request.url, headers, request.body) - f.write(message) + dumpfile.write(message) return mock.Mock() def patch_request(method, url, **kwargs): with requests.sessions.Session() as session: parseresult = urlparse.urlparse(url) if parseresult.scheme == "file": - with mock.patch.object( - session, 'send', side_effect=dump_preparedrequest): + with mock.patch.object(session, 'send', + side_effect=dump_preparedrequest): return session.request(method=method, url=url, **kwargs) else: return session.request(method=method, url=url, **kwargs) -- cgit 1.2.3-korg