[nft,7/7] test: py: Make diff functions use print_* functions

Message ID 534773f16df5a64cfe21b34ad1d3a161b61bad17.1526542126.git.ecklm94@gmail.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series
  • Python test fixes
Related show

Commit Message

Máté Eckl May 17, 2018, 7:37 a.m.
Signed-off-by: Máté Eckl <ecklm94@gmail.com>
---
 tests/py/nft-test.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Patch

diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index b536e9c..edc0b4b 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -161,15 +161,13 @@  def color_differences(rule, other, color):
 def print_differences_warning(filename, lineno, rule1, rule2, cmd):
     colored_rule1 = color_differences(rule1, rule2, Colors.YELLOW)
     colored_rule2 = color_differences(rule2, rule1, Colors.YELLOW)
-    reason = "'" + colored_rule1 + "' mismatches '" + colored_rule2 + "'"
-    print filename + ": " + Colors.YELLOW + "WARNING: " + Colors.ENDC + \
-          "line: " + str(lineno + 1) + ": '" + cmd + "': " + reason
+    reason = "'%s': '%s' mismatches '%s'" % (cmd, colored_rule1, colored_rule2)
+    print_warning(reason, filename, lineno)
 
 
 def print_differences_error(filename, lineno, cmd):
-    reason = "Listing is broken."
-    print filename + ": " + Colors.RED + "ERROR: " + Colors.ENDC + "line: " + \
-          str(lineno + 1) + ": '" + cmd + "': " + reason
+    reason = "'%s': Listing is broken." % cmd
+    print_error(reason, filename, lineno)
 
 
 def table_exist(table, filename, lineno):