summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Dong <michael.dong@rackspace.com>2018-10-18 14:39:59 -0500
committerMichael Dong <michael.dong@rackspace.com>2018-10-18 14:39:59 -0500
commita6db29dc7c1ff4e3a623652dbc396bee09863430 (patch)
treed62795f1df5aeefcbb4afc93aed1a0d8dbc84a02
parentfeb3a59c955bea096d65b65e90d816856c42bc26 (diff)
Bug fixes related to python 3 changes
Notes
Notes (review): Workflow+1: Michael Dong <michael.dong@rackspace.com> Code-Review+2: Michael Dong <michael.dong@rackspace.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 18 Oct 2018 22:28:55 +0000 Reviewed-on: https://review.openstack.org/611702 Project: openstack/syntribos Branch: refs/heads/master
-rw-r--r--syntribos/clients/http/parser.py8
-rw-r--r--syntribos/runner.py2
-rw-r--r--syntribos/tests/fuzz/base_fuzz.py2
-rw-r--r--syntribos/utils/string_utils.py2
4 files changed, 7 insertions, 7 deletions
diff --git a/syntribos/clients/http/parser.py b/syntribos/clients/http/parser.py
index 25e0919..8c8c220 100644
--- a/syntribos/clients/http/parser.py
+++ b/syntribos/clients/http/parser.py
@@ -36,7 +36,7 @@ _string_var_objs = {}
36 36
37class RequestCreator(object): 37class RequestCreator(object):
38 ACTION_FIELD = "ACTION_FIELD:" 38 ACTION_FIELD = "ACTION_FIELD:"
39 EXTERNAL = r"CALL_EXTERNAL\|([^:]+?):([^:]+?):([^|]+?)\|" 39 EXTERNAL = r"CALL_EXTERNAL\|([^:]+?):([^:]+?)(?::([^|]+?))?\|"
40 METAVAR = r"(\|[^\|]*\|)" 40 METAVAR = r"(\|[^\|]*\|)"
41 FUNC_WITH_ARGS = r"([^:]+):([^:]+):(\[.+\])" 41 FUNC_WITH_ARGS = r"([^:]+):([^:]+):(\[.+\])"
42 FUNC_NO_ARGS = r"([^:]+):([^:]+)" 42 FUNC_NO_ARGS = r"([^:]+):([^:]+)"
@@ -85,9 +85,9 @@ class RequestCreator(object):
85 """ 85 """
86 if not cls.meta_vars: 86 if not cls.meta_vars:
87 msg = ("Template contains reference to meta variable of the form " 87 msg = ("Template contains reference to meta variable of the form "
88 "\'|variable|\', but no meta.json file is found in the" 88 "'|{}|', but no meta.json file is found in the"
89 "templates directory. Check your templates and the " 89 "templates directory. Check your templates and the "
90 "documentation on how to resolve this") 90 "documentation on how to resolve this".format(var))
91 raise TemplateParseException(msg) 91 raise TemplateParseException(msg)
92 92
93 if var not in cls.meta_vars: 93 if var not in cls.meta_vars:
@@ -326,7 +326,7 @@ class RequestCreator(object):
326 break 326 break
327 dot_path = match.group(1) 327 dot_path = match.group(1)
328 func_name = match.group(2) 328 func_name = match.group(2)
329 arg_list = match.group(3) 329 arg_list = match.group(3) or "[]"
330 mod = importlib.import_module(dot_path) 330 mod = importlib.import_module(dot_path)
331 func = getattr(mod, func_name) 331 func = getattr(mod, func_name)
332 args = json.loads(arg_list) 332 args = json.loads(arg_list)
diff --git a/syntribos/runner.py b/syntribos/runner.py
index 8563a73..045711a 100644
--- a/syntribos/runner.py
+++ b/syntribos/runner.py
@@ -415,7 +415,7 @@ class Runner(object):
415 failures = result.stats['unique_failures'] - last_failures 415 failures = result.stats['unique_failures'] - last_failures
416 errors = result.stats['errors'] - last_errors 416 errors = result.stats['errors'] - last_errors
417 failures_str = cli.colorize_by_percent( 417 failures_str = cli.colorize_by_percent(
418 failures, total_tests, "red") 418 failures, total_tests)
419 419
420 if errors: 420 if errors:
421 errors_str = cli.colorize(errors, "red") 421 errors_str = cli.colorize(errors, "red")
diff --git a/syntribos/tests/fuzz/base_fuzz.py b/syntribos/tests/fuzz/base_fuzz.py
index 8f4f6ed..37bc30c 100644
--- a/syntribos/tests/fuzz/base_fuzz.py
+++ b/syntribos/tests/fuzz/base_fuzz.py
@@ -50,7 +50,7 @@ class BaseFuzzTestCase(base.BaseTestCase):
50 else: 50 else:
51 path = os.path.join(payloads, file_name or cls.data_key) 51 path = os.path.join(payloads, file_name or cls.data_key)
52 with open(path, "rb") as fp: 52 with open(path, "rb") as fp:
53 return fp.read().splitlines() 53 return str(fp.read()).splitlines()
54 except (IOError, AttributeError, TypeError) as e: 54 except (IOError, AttributeError, TypeError) as e:
55 LOG.error("Exception raised: {}".format(e)) 55 LOG.error("Exception raised: {}".format(e))
56 print("\nPayload file for test '{}' not readable, " 56 print("\nPayload file for test '{}' not readable, "
diff --git a/syntribos/utils/string_utils.py b/syntribos/utils/string_utils.py
index a8ecaee..8d4b5a8 100644
--- a/syntribos/utils/string_utils.py
+++ b/syntribos/utils/string_utils.py
@@ -87,7 +87,7 @@ def compress(content, threshold=512):
87 compressed_data = base64.b64encode( 87 compressed_data = base64.b64encode(
88 zlib.compress(bytes(content.encode("utf-8")))) 88 zlib.compress(bytes(content.encode("utf-8"))))
89 if not six.PY2: 89 if not six.PY2:
90 compressed_data = compressed_data.decode("utf-8") 90 compressed_data = str(compressed_data.decode("utf-8"))
91 return pprint.pformat( 91 return pprint.pformat(
92 "\n***Content compressed by Syntribos.***" 92 "\n***Content compressed by Syntribos.***"
93 "\nFirst fifty characters of content:\n" 93 "\nFirst fifty characters of content:\n"