|
@@ -21,6 +21,9 @@ from threading import Event
|
|
|
|
|
|
from utils import header
|
|
|
|
|
|
+# Cross-platform colored text
|
|
|
+from colorama import Fore, Back, Style
|
|
|
+
|
|
|
class FrameworkTest:
|
|
|
headers_template = "-H 'Host: localhost' -H '{accept}' -H 'Connection: keep-alive'"
|
|
|
|
|
@@ -289,8 +292,15 @@ class FrameworkTest:
|
|
|
test.passed = all(result is 'pass' for (result, reason, url) in results)
|
|
|
|
|
|
def output_result(result, reason, url):
|
|
|
- out.write(" %s for %s\n" % (result.upper(), url))
|
|
|
- print " %s for %s" % (result.upper(), url)
|
|
|
+ prefix = Fore.CYAN
|
|
|
+ color = Fore.GREEN
|
|
|
+ if result.upper() == "WARN":
|
|
|
+ color = Fore.YELLOW
|
|
|
+ elif result.upper() == "FAIL":
|
|
|
+ color = Fore.RED
|
|
|
+
|
|
|
+ out.write(prefix + " " + color + "%s" + Style.RESET_ALL + " for %s\n" % (result.upper(), url))
|
|
|
+ print prefix + " " + color + "%s" + Style.RESET_ALL + " for %s" % (result.upper(), url)
|
|
|
if reason is not None and len(reason) != 0:
|
|
|
for line in reason.splitlines():
|
|
|
out.write(" " + line + '\n')
|