diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-04-20 15:24:47 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-04-20 15:24:47 +0200 |
commit | 8a20ff549efc9d6ada5695c7e32f03663340130d (patch) | |
tree | cc02d3bf0f5cdf934f6f6951c836b5c2fc6d2444 /functest | |
parent | 7e15dbb5136b1b298d86a82c03199bf1f7a6fe46 (diff) |
Fix pylint warnings in decorators.py
Change-Id: Ie6c53feb97053248c909d641753b44b5f51c8719
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest')
-rw-r--r-- | functest/utils/decorators.py | 20 |
1 files changed, 12 insertions, 8 deletions
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) |