aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils/decorators.py
diff options
context:
space:
mode:
Diffstat (limited to 'functest/utils/decorators.py')
-rw-r--r--functest/utils/decorators.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/functest/utils/decorators.py b/functest/utils/decorators.py
index 46ffe35d..73e0a352 100644
--- a/functest/utils/decorators.py
+++ b/functest/utils/decorators.py
@@ -3,18 +3,19 @@
# pylint: disable=missing-docstring
import errno
+import functools
import os
-import urlparse
import mock
import requests.sessions
+from six.moves import urllib
def can_dump_request_to_file(method):
def dump_preparedrequest(request, **kwargs):
# pylint: disable=unused-argument
- parseresult = urlparse.urlparse(request.url)
+ parseresult = urllib.parse.urlparse(request.url)
if parseresult.scheme == "file":
try:
dirname = os.path.dirname(parseresult.path)
@@ -33,7 +34,7 @@ def can_dump_request_to_file(method):
def patch_request(method, url, **kwargs):
with requests.sessions.Session() as session:
- parseresult = urlparse.urlparse(url)
+ parseresult = urllib.parse.urlparse(url)
if parseresult.scheme == "file":
with mock.patch.object(session, 'send',
side_effect=dump_preparedrequest):
@@ -41,6 +42,7 @@ def can_dump_request_to_file(method):
else:
return session.request(method=method, url=url, **kwargs)
+ @functools.wraps(method)
def hook(*args, **kwargs):
with mock.patch('requests.api.request', side_effect=patch_request):
return method(*args, **kwargs)