Browse Source

Bug fixes related to python 3 changes

Change-Id: I048bb19cf456281521883eb1500832343d72fb97
changes/02/611702/1
Michael Dong 8 months ago
parent
commit
a6db29dc7c

+ 4
- 4
syntribos/clients/http/parser.py View File

@@ -36,7 +36,7 @@ _string_var_objs = {}
36 36
 
37 37
 class RequestCreator(object):
38 38
     ACTION_FIELD = "ACTION_FIELD:"
39
-    EXTERNAL = r"CALL_EXTERNAL\|([^:]+?):([^:]+?):([^|]+?)\|"
39
+    EXTERNAL = r"CALL_EXTERNAL\|([^:]+?):([^:]+?)(?::([^|]+?))?\|"
40 40
     METAVAR = r"(\|[^\|]*\|)"
41 41
     FUNC_WITH_ARGS = r"([^:]+):([^:]+):(\[.+\])"
42 42
     FUNC_NO_ARGS = r"([^:]+):([^:]+)"
@@ -85,9 +85,9 @@ class RequestCreator(object):
85 85
         """
86 86
         if not cls.meta_vars:
87 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 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 91
             raise TemplateParseException(msg)
92 92
 
93 93
         if var not in cls.meta_vars:
@@ -326,7 +326,7 @@ class RequestCreator(object):
326 326
                 break
327 327
             dot_path = match.group(1)
328 328
             func_name = match.group(2)
329
-            arg_list = match.group(3)
329
+            arg_list = match.group(3) or "[]"
330 330
             mod = importlib.import_module(dot_path)
331 331
             func = getattr(mod, func_name)
332 332
             args = json.loads(arg_list)

+ 1
- 1
syntribos/runner.py View File

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

+ 1
- 1
syntribos/tests/fuzz/base_fuzz.py View File

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

+ 1
- 1
syntribos/utils/string_utils.py View File

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

Loading…
Cancel
Save