diff --git a/testenv/ChangeLog b/testenv/ChangeLog index 85bd0f2b..68894458 100644 --- a/testenv/ChangeLog +++ b/testenv/ChangeLog @@ -1,3 +1,15 @@ +2014-03-13 Zihang Chen + + * 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 * 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/README b/testenv/README index 09f226a9..487541db 100644 --- a/testenv/README +++ b/testenv/README @@ -10,7 +10,7 @@ Run the './configure' command to generate the Makefile and then run 'make check' to execute the Test Suite. Use the '-j n' option with 'make check' to execute n tests simultaneously. -File List: +Structure: ================================================================================ * HTTPServer.py: This file contains a custom, programmatically configurable @@ -26,8 +26,11 @@ File List: the acceptable elements and their uses. Typically, one must copy this file and edit it for writing Test Cases. - * ColourTerm.py: A custom library for printing coloured output to the - terminal. Currently it only supports 4 colours in a *nix environment. + * misc: This package contains several helper modules used in this test + suite. + - colour_terminal.py: A custom module for printing coloured output to + the terminal. Currently it only supports 4 colours in a *nix + environment. Working: ================================================================================ diff --git a/testenv/WgetTest.py b/testenv/WgetTest.py index 6470d936..c0961e11 100644 --- a/testenv/WgetTest.py +++ b/testenv/WgetTest.py @@ -7,7 +7,7 @@ import HTTPServer import re import time from subprocess import call -from ColourTerm import printer +from misc.colour_terminal import print_red, print_green, print_blue from difflib import unified_diff HTTP = "HTTP" @@ -213,7 +213,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 +236,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 +252,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 00000000..8b137891 --- /dev/null +++ b/testenv/misc/__init__.py @@ -0,0 +1 @@ + diff --git a/testenv/ColourTerm.py b/testenv/misc/colour_terminal.py similarity index 68% rename from testenv/ColourTerm.py rename to testenv/misc/colour_terminal.py index d8f67692..206ffa30 100644 --- a/testenv/ColourTerm.py +++ b/testenv/misc/colour_terminal.py @@ -1,3 +1,4 @@ +from functools import partial import platform from os import getenv @@ -20,4 +21,11 @@ def printer (color, string): 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 :