diff options
author | Cedric Ollivier <cedric.ollivier@orange.com> | 2017-04-21 07:42:03 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-04-21 07:42:03 +0000 |
commit | b4f1fd63dea0b67654be7b3c0239fbada1bfcafa (patch) | |
tree | 60b9d5c0ae162098dd971d63cde151bb19be15ea | |
parent | 7ebf2d7f41d8935012388f95ea5525bd9d39fdc0 (diff) | |
parent | 8a20ff549efc9d6ada5695c7e32f03663340130d (diff) |
Merge "Fix pylint warnings in decorators.py"
-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 2ca31066d..46ffe35d1 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) |