From: Cédric Ollivier Date: Thu, 20 Apr 2017 13:24:47 +0000 (+0200) Subject: Fix pylint warnings in decorators.py X-Git-Tag: 0.2~703^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=8a20ff549efc9d6ada5695c7e32f03663340130d;p=functest-xtesting.git Fix pylint warnings in decorators.py Change-Id: Ie6c53feb97053248c909d641753b44b5f51c8719 Signed-off-by: Cédric Ollivier --- 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)