[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-wget] [GSoC PATCH 01/11] create package misc, move ColourTerm.py to
From: |
Zihang Chen |
Subject: |
[Bug-wget] [GSoC PATCH 01/11] create package misc, move ColourTerm.py to misc |
Date: |
Fri, 14 Mar 2014 21:18:17 +0800 |
delete mode 100644 testenv/ColourTerm.py
create mode 100644 testenv/misc/__init__.py
create mode 100644 testenv/misc/colour_terminal.py
diff --git a/testenv/ChangeLog b/testenv/ChangeLog
index 85bd0f2..dc0878f 100644
--- a/testenv/ChangeLog
+++ b/testenv/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-13 Zihang Chen <address@hidden>
+ * misc: (new package) package for miscellaneous modules
+ * ColourTerm.py: Move to package misc and rename to colour_terminal.py,
+ add print_color functions to reduce the use of string literals like
+ "BLUE", "RED" etc.
+ * WgetTest.py:
+ (CommonMethods.Server_setup): Change invocation to printer to
print_blue.
+ (CommonMethods.FilesCrawled): Change invocation to printer to print_red.
+ (HTTPTest.__init__): Change invocations to printer to print_red and
+ print_green respectively.
2014-01-02 Darshit Shah <address@hidden>
* Makefile.am: Add new Test--https.py to list of tests and EXTRA_DIST.
Also replace all tabs with spaces in file for conformity.
diff --git a/testenv/ColourTerm.py b/testenv/ColourTerm.py
deleted file mode 100644
index d8f6769..0000000
--- a/testenv/ColourTerm.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import platform
-from os import getenv
-
-T_COLORS = {
- 'PURPLE' : '\033[95m',
- 'BLUE' : '\033[94m',
- 'GREEN' : '\033[92m',
- 'YELLOW' : '\033[93m',
- 'RED' : '\033[91m',
- 'ENDC' : '\033[0m'
-}
-
-def printer (color, string):
- if platform.system () == 'Linux':
- if getenv ("MAKE_CHECK", "False") == "True":
- print (string)
- else:
- print (T_COLORS.get (color) + string + T_COLORS.get ('ENDC'))
-
- else:
- print (string)
-
-# vim: set ts=8 sw=3 tw=0 et :
diff --git a/testenv/WgetTest.py b/testenv/WgetTest.py
index 6470d93..ba34d8d 100644
--- a/testenv/WgetTest.py
+++ b/testenv/WgetTest.py
@@ -3,13 +3,15 @@ import shutil
import shlex
import sys
import traceback
-import HTTPServer
import re
import time
from subprocess import call
-from ColourTerm import printer
from difflib import unified_diff
+import HTTPServer
+from misc.colour_terminal import print_red, print_green, print_blue
+
+
HTTP = "HTTP"
HTTPS = "HTTPS"
@@ -213,7 +215,7 @@ class CommonMethods:
o_headers = self.Request_remaining[i]
header_diff = headers.symmetric_difference (o_headers)
if len(header_diff) is not 0:
- printer ("RED", str (header_diff))
+ print_red(header_diff)
raise TestFailed ("Not all files were crawled correctly")
@@ -236,15 +238,15 @@ class HTTPTest (CommonMethods):
try:
self.Server_setup (name, pre_hook, test_params, post_hook, servers)
except TestFailed as tf:
- printer ("RED", "Error: " + tf.error)
+ print_red("Error: " + tf.error)
self.tests_passed = False
except Exception as ae:
- printer ("RED", "Unhandled Exception Caught.")
+ print_red("Unhandled Exception Caught.")
print ( ae.__str__ ())
traceback.print_exc ()
self.tests_passed = False
else:
- printer ("GREEN", "Test Passed")
+ print_green("Test Passed")
finally:
self._exit_test ()
@@ -252,7 +254,7 @@ class HTTPTest (CommonMethods):
self.name = name
self.server_types = servers
self.servers = len (servers)
- printer ("BLUE", "Running Test " + self.name)
+ print_blue("Running Test " + self.name)
self.init_test_env (name)
self.server_list = list()
self.domain_list = list()
diff --git a/testenv/misc/__init__.py b/testenv/misc/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/testenv/misc/colour_terminal.py b/testenv/misc/colour_terminal.py
new file mode 100644
index 0000000..a34277c
--- /dev/null
+++ b/testenv/misc/colour_terminal.py
@@ -0,0 +1,31 @@
+from functools import partial
+import platform
+from os import getenv
+
+T_COLORS = {
+ 'PURPLE' : '\033[95m',
+ 'BLUE' : '\033[94m',
+ 'GREEN' : '\033[92m',
+ 'YELLOW' : '\033[93m',
+ 'RED' : '\033[91m',
+ 'ENDC' : '\033[0m'
+}
+
+def printer (color, string):
+ if platform.system () == 'Linux':
+ if getenv ("MAKE_CHECK", "False") == "True":
+ print (string)
+ else:
+ print (T_COLORS.get (color) + string + T_COLORS.get ('ENDC'))
+
+ else:
+ print (string)
+
+
+print_blue = partial(printer, 'BLUE')
+print_red = partial(printer, 'RED')
+print_green = partial(printer, 'GREEN')
+print_purple = partial(printer, 'PURPLE')
+print_yellow = partial(printer, 'YELLOW')
+
+# vim: set ts=8 sw=3 tw=0 et :
\ No newline at end of file
--
1.8.3.2
- [Bug-wget] [GSoC PATCH 00/11] Refactor Test Suite, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 01/11] create package misc, move ColourTerm.py to misc,
Zihang Chen <=
- [Bug-wget] [GSoC PATCH 02/11] from WgetTest.py move WgetFile to misc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 03/11] fix a typo in Test-Proto.py, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 04/11] create package exc and move TestFailed to exc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 05/11] create package conf where rules and hooks are put, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 06/11] move server classes to package server.protocol, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 07/11] create package test for test case classes, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 08/11] refactor a lot, see ChangeLog for detail, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 09/11] update README, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 10/11] ensure line feed at EOF and one blank line between methods, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 11/11] in conf, rename register to rule and hook, Zihang Chen, 2014/03/14