aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2017-03-23 10:31:36 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-23 10:31:36 +0000
commit1faa8c6f81143885c19128f043c3fd7604402c23 (patch)
tree1693bdbc1ecdd5a937180017de90fa7b89af4768 /functest/utils
parente6f875c4a756245c47211483247fe3674fd73834 (diff)
parent18bdde48e866f198b5d08b62fc9e26e3dfe4e818 (diff)
Merge "Switch test_db_url to a directory"
Diffstat (limited to 'functest/utils')
-rw-r--r--functest/utils/decorators.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/functest/utils/decorators.py b/functest/utils/decorators.py
index 99bcef3e6..276235d96 100644
--- a/functest/utils/decorators.py
+++ b/functest/utils/decorators.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
+import errno
import mock
+import os
import requests.sessions
import urlparse
@@ -10,7 +12,12 @@ def can_dump_request_to_file(method):
def dump_preparedrequest(request, **kwargs):
parseresult = urlparse.urlparse(request.url)
if parseresult.scheme == "file":
- with open(parseresult.path.replace('/results', ''), 'a') as f:
+ try:
+ os.makedirs(parseresult.path)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+ with open(os.path.join(parseresult.path, 'dump.txt'), 'a') as f:
headers = ""
for key in request.headers:
headers += key + " " + request.headers[key] + "\n"