Author: bugman Date: Sat Jan 13 11:00:17 2007 New Revision: 3004 URL: http://svn.gna.org/viewcvs/relax?rev=3004&view=rev Log: Changes to the output formatting functions of the test suite. The methods 'self.heading()' and 'self.summary_line()' have been converted to functions and have been shifted from the file 'test_suite/system_tests/main.py' into the new file 'test_suite/formatting.py'. The final printout by 'test_suite/runner.py' now used these functions. Added: 1.3/test_suite/formatting.py Modified: 1.3/test_suite/runner.py 1.3/test_suite/system_tests/main.py Added: 1.3/test_suite/formatting.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/formatting.py?rev=3004&view=auto ============================================================================== --- 1.3/test_suite/formatting.py (added) +++ 1.3/test_suite/formatting.py Sat Jan 13 11:00:17 2007 @@ -1,0 +1,73 @@ +############################################################################### +# # +# Copyright (C) 2007 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +import sys + + +def heading(text): + """Function for printing the headings. + + @param text: The text of the heading to be printed. + @type text: str + """ + + # Spacing. + sys.stdout.write("\n\n\n\n") + + # Top bar. + for i in xrange(len(text) + 4): + sys.stdout.write("#") + sys.stdout.write("\n") + + # Text. + sys.stdout.write("# " + text + " #\n") + + # Bottom bar. + for i in xrange(len(text) + 4): + sys.stdout.write("#") + sys.stdout.write("\n\n\n") + + +def summary_line(name, passed): + """Print a summary line. + + @param name: The name of the test, test category, etc. + @type name: str + @param passed: An argment which if True causes '[ OK ]' to be printed and if False causes + '[ Failed ]' to be printed. + @type passed: Any objects which evaluates to either True or False. + """ + + # Name. + sys.stdout.write(" " + name + " ") + + # Dots. + for j in xrange(84 - len(name)): + sys.stdout.write(".") + + # Passed. + if passed: + sys.stdout.write(" %-10s\n" % "[ OK ]") + + # Failed. + else: + sys.stdout.write(" %-10s\n" % "[ Failed ]") Modified: 1.3/test_suite/runner.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/runner.py?rev=3004&r1=3003&r2=3004&view=diff ============================================================================== --- 1.3/test_suite/runner.py (original) +++ 1.3/test_suite/runner.py Sat Jan 13 11:00:17 2007 @@ -19,6 +19,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # ############################################################################### + +# Formatting. +from formatting import * # Import the test suite categories. from system_tests.main import System_tests @@ -56,10 +59,13 @@ print "\n\n\n" print "###################################" print "# Summary of the relax test suite #" - print "###################################" + print "###################################\n" - # System/functional tests. - print "System/functional tests: " + `system_result` + # System/functional test summary. + summary_line("System/functional tests", system_result) - # Unit tests. - print "Unit tests: " + `unit_result` + # Unit test summary. + summary_line("Unit tests", unit_result) + + # Synopsis. + summary_line("Synopsis", system_result and unit_result) Modified: 1.3/test_suite/system_tests/main.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/main.py?rev=3004&r1=3003&r2=3004&view=diff ============================================================================== --- 1.3/test_suite/system_tests/main.py (original) +++ 1.3/test_suite/system_tests/main.py Sat Jan 13 11:00:17 2007 @@ -24,6 +24,8 @@ import traceback import sys +# Formatting. +from test_suite.formatting import * # Import the tests. from angles import Angles @@ -54,14 +56,14 @@ ############### # Heading. - self.heading("The relax test suite") + heading("The relax test suite") # Run tests. ############ # Heading. - self.heading("The run tests") + heading("The run tests") # Initialise the array containing each test element. self.run_test_array = [] @@ -77,7 +79,7 @@ ################# # Heading. - self.heading("The sequence tests") + heading("The sequence tests") # Initialise the array containing each test element. self.seq_test_array = [] @@ -96,7 +98,7 @@ ######################### # Heading. - self.heading("The diffusion tensor tests") + heading("The diffusion tensor tests") # Initialise the array containing each test element. self.diff_tensor_test_array = [] @@ -115,7 +117,7 @@ ########################## # Heading. - self.heading("Angle calculation tests") + heading("Angle calculation tests") # Initialise the array containing each test element. self.angles_test_array = [] @@ -131,7 +133,7 @@ ################################# # Heading. - self.heading("The relaxation curve-fitting tests") + heading("The relaxation curve-fitting tests") # Initialise the array containing each test element. self.relax_fit_test_array = [] @@ -147,7 +149,7 @@ ################### # Heading. - self.heading("The model-free tests") + heading("The model-free tests") # Initialise the array containing each test element. self.mf_test_array = [] @@ -181,7 +183,7 @@ ######################################### # Heading. - self.heading("The reduced spectral density mapping tests") + heading("The reduced spectral density mapping tests") # Initialise the array containing each test element. self.jw_test_array = [] @@ -198,7 +200,7 @@ ######################## # Heading. - self.heading("The model selection tests") + heading("The model selection tests") # Initialise the array containing each test element. self.modsel_test_array = [] @@ -214,7 +216,7 @@ ################ # Heading. - self.heading("The generic tests") + heading("The generic tests") # Initialise the array containing each test element. self.generic_test_array = [] @@ -231,26 +233,6 @@ self.summary() - - - def heading(self, text): - """Function for printing the headings.""" - - # Spacing. - sys.stdout.write("\n\n\n\n") - - # Top bar. - for i in xrange(len(text) + 4): - sys.stdout.write("#") - sys.stdout.write("\n") - - # Text. - sys.stdout.write("# " + text + " #\n") - - # Bottom bar. - for i in xrange(len(text) + 4): - sys.stdout.write("#") - sys.stdout.write("\n\n\n") def exec_tests(self, test_array): @@ -295,7 +277,7 @@ # Heading. sys.stdout.write("\n\n\n") - self.heading("Results of the test suite") + heading("Results of the test suite") # Flag for all tests. self.global_pass = 1 @@ -309,7 +291,7 @@ # Loop over the tests. for test in self.run_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Sequence tests. @@ -320,7 +302,7 @@ # Loop over the tests. for test in self.seq_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Diffusion tensor tests. @@ -331,7 +313,7 @@ # Loop over the tests. for test in self.diff_tensor_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Angle calculation tests. @@ -342,7 +324,7 @@ # Loop over the tests. for test in self.angles_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Relaxation curve-fitting tests. @@ -353,7 +335,7 @@ # Loop over the tests. for test in self.relax_fit_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Model-free tests. @@ -364,7 +346,7 @@ # Loop over the tests. for test in self.mf_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Reduced spectral density Mapping tests. @@ -375,7 +357,7 @@ # Loop over the tests. for test in self.jw_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Model selection tests. @@ -386,7 +368,7 @@ # Loop over the tests. for test in self.modsel_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Generic tests. @@ -397,7 +379,7 @@ # Loop over the tests. for test in self.generic_test_array: - self.summary_line(test) + summary_line(test.name, test.passed) # Synposis. @@ -418,23 +400,3 @@ else: sys.stdout.write(" %-10s\n" % "[ Failed ]") sys.stdout.write("\n\n") - - - def summary_line(self, test): - """Function for printing the summary lines.""" - - # Name. - sys.stdout.write(" " + test.name + " ") - - # Dots. - for j in xrange(84 - len(test.name)): - sys.stdout.write(".") - - # Passed. - if test.passed: - sys.stdout.write(" %-10s\n" % "[ OK ]") - - # Failed. - else: - sys.stdout.write(" %-10s\n" % "[ Failed ]") - self.global_pass = 0