about summary refs log tree commit diff stats
path: root/test/utils
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils')
-rw-r--r--test/utils/cosmetics.py29
-rw-r--r--test/utils/multithread.py21
-rw-r--r--test/utils/testset.py10
3 files changed, 34 insertions, 26 deletions
diff --git a/test/utils/cosmetics.py b/test/utils/cosmetics.py
index e80e1f09..da7a6bc5 100644
--- a/test/utils/cosmetics.py
+++ b/test/utils/cosmetics.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 import os
 import platform
 
@@ -33,23 +34,27 @@ def getTerminalSize():
 
 
 WIDTH = getTerminalSize()[0]
-colors = {"red": "\033[91;1m",
-          "end": "\033[0m",
-          "green": "\033[92;1m",
-          "lightcyan": "\033[96m",
-          "blue": "\033[94;1m"}
+colors = {
+    "red": "\033[91;1m",
+    "end": "\033[0m",
+    "green": "\033[92;1m",
+    "lightcyan": "\033[96m",
+    "blue": "\033[94;1m"
+}
 
 if is_win:
-    colors = {"red": "",
-              "end": "",
-              "green": "",
-              "lightcyan": "",
-              "blue": ""}
+    colors = {
+        "red": "",
+        "end": "",
+        "green": "",
+        "lightcyan": "",
+        "blue": ""
+    }
 
 def write_colored(text, color, already_printed=0):
     text_colored = colors[color] + text + colors["end"]
-    print " " * (WIDTH - already_printed - len(text)) + text_colored
+    print(" " * (WIDTH - already_printed - len(text)) + text_colored)
 
 
 def write_underline(text):
-    print "\033[4m" + text + colors["end"]
+    print("\033[4m" + text + colors["end"])
diff --git a/test/utils/multithread.py b/test/utils/multithread.py
index 287b5ebd..d0874dd1 100644
--- a/test/utils/multithread.py
+++ b/test/utils/multithread.py
@@ -1,24 +1,25 @@
+from __future__ import print_function
 import sys
-import cosmetics
+from . import cosmetics
 import time
 
 
 def task_done(test, error, test_ok, test_ko):
     command_line = " ".join(test.command_line)
     if error is not None:
-        print cosmetics.colors["red"] + 'ERROR',
-        print cosmetics.colors["lightcyan"] + command_line + cosmetics.colors["end"]
-        print error
+        print(cosmetics.colors["red"] + 'ERROR', end=' ')
+        print(cosmetics.colors["lightcyan"] + command_line + cosmetics.colors["end"])
+        print(error)
         test_ko.append((test, error))
     else:
-        print cosmetics.colors["green"] + 'DONE',
-        print cosmetics.colors["lightcyan"] + command_line + cosmetics.colors["end"],
-        print "%ds" % (time.time() - test.start_time)
+        print(cosmetics.colors["green"] + 'DONE', end=' ')
+        print(cosmetics.colors["lightcyan"] + command_line + cosmetics.colors["end"], end=' ')
+        print("%ds" % (time.time() - test.start_time))
         test_ok.append((test, error))
 
 
 def task_new(test):
     command_line = " ".join(test.command_line)
-    print cosmetics.colors["lightcyan"],
-    print test.base_dir.upper(), command_line,
-    print cosmetics.colors["end"]
+    print(cosmetics.colors["lightcyan"], end=' ')
+    print(test.base_dir.upper(), command_line, end=' ')
+    print(cosmetics.colors["end"])
diff --git a/test/utils/testset.py b/test/utils/testset.py
index 7b60e836..eee0e6f7 100644
--- a/test/utils/testset.py
+++ b/test/utils/testset.py
@@ -1,10 +1,12 @@
+from __future__ import print_function
+from builtins import range
 import os
 import subprocess
 import sys
 import time
 from multiprocessing import cpu_count, Queue, Process
 
-from test import Test
+from .test import Test
 
 
 class Message(object):
@@ -136,7 +138,7 @@ class TestSet(object):
 
         if len(self.tests) == 0:
             # Poison pills
-            for _ in xrange(self.cpu_c):
+            for _ in range(self.cpu_c):
                 self.todo_queue.put(None)
 
         # All tasks done
@@ -201,7 +203,7 @@ class TestSet(object):
             try:
                 os.remove(product)
             except OSError:
-                print "Cleanning error: Unable to remove %s" % product
+                print("Cleanning error: Unable to remove %s" % product)
 
     def add_additional_args(self, args):
         """Add arguments to used on the test command line
@@ -218,7 +220,7 @@ class TestSet(object):
 
         # Launch workers
         processes = []
-        for _ in xrange(self.cpu_c):
+        for _ in range(self.cpu_c):
             p = Process(target=TestSet.worker, args=(self.todo_queue,
                                                      self.message_queue,
                                                      self.additional_args))