Bug fixes related to python 3 changes

Change-Id: I048bb19cf456281521883eb1500832343d72fb97
This commit is contained in:
Michael Dong 2018-10-18 14:39:59 -05:00
parent feb3a59c95
commit a6db29dc7c
4 changed files with 7 additions and 7 deletions

View File

@ -36,7 +36,7 @@ _string_var_objs = {}
class RequestCreator(object):
ACTION_FIELD = "ACTION_FIELD:"
EXTERNAL = r"CALL_EXTERNAL\|([^:]+?):([^:]+?):([^|]+?)\|"
EXTERNAL = r"CALL_EXTERNAL\|([^:]+?):([^:]+?)(?::([^|]+?))?\|"
METAVAR = r"(\|[^\|]*\|)"
FUNC_WITH_ARGS = r"([^:]+):([^:]+):(\[.+\])"
FUNC_NO_ARGS = r"([^:]+):([^:]+)"
@ -85,9 +85,9 @@ class RequestCreator(object):
"""
if not cls.meta_vars:
msg = ("Template contains reference to meta variable of the form "
"\'|variable|\', but no meta.json file is found in the"
"'|{}|', but no meta.json file is found in the"
"templates directory. Check your templates and the "
"documentation on how to resolve this")
"documentation on how to resolve this".format(var))
raise TemplateParseException(msg)
if var not in cls.meta_vars:
@ -326,7 +326,7 @@ class RequestCreator(object):
break
dot_path = match.group(1)
func_name = match.group(2)
arg_list = match.group(3)
arg_list = match.group(3) or "[]"
mod = importlib.import_module(dot_path)
func = getattr(mod, func_name)
args = json.loads(arg_list)

View File

@ -415,7 +415,7 @@ class Runner(object):
failures = result.stats['unique_failures'] - last_failures
errors = result.stats['errors'] - last_errors
failures_str = cli.colorize_by_percent(
failures, total_tests, "red")
failures, total_tests)
if errors:
errors_str = cli.colorize(errors, "red")

View File

@ -50,7 +50,7 @@ class BaseFuzzTestCase(base.BaseTestCase):
else:
path = os.path.join(payloads, file_name or cls.data_key)
with open(path, "rb") as fp:
return fp.read().splitlines()
return str(fp.read()).splitlines()
except (IOError, AttributeError, TypeError) as e:
LOG.error("Exception raised: {}".format(e))
print("\nPayload file for test '{}' not readable, "

View File

@ -87,7 +87,7 @@ def compress(content, threshold=512):
compressed_data = base64.b64encode(
zlib.compress(bytes(content.encode("utf-8"))))
if not six.PY2:
compressed_data = compressed_data.decode("utf-8")
compressed_data = str(compressed_data.decode("utf-8"))
return pprint.pformat(
"\n***Content compressed by Syntribos.***"
"\nFirst fifty characters of content:\n"