Package test_suite :: Module formatting
[hide private]
[frames] | no frames]

Source Code for Module test_suite.formatting

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  import sys 
 25   
 26   
27 -def subtitle(text):
28 """Function for printing the subtitles. 29 30 @param text: The text of the subtitle to be printed. 31 @type text: str 32 """ 33 34 # The width of the subtitle string. 35 width = len(text) + 2 36 37 # Text. 38 sys.stdout.write("# %s\n" % text) 39 40 # Bottom bar. 41 sys.stdout.write("#" * width) 42 43 # Spacing. 44 sys.stdout.write("\n\n")
45 46
47 -def summary_line(name, passed, width=64):
48 """Print a summary line. 49 50 @param name: The name of the test, test category, etc. 51 @type name: str 52 @param passed: An argument which if True causes '[ OK ]' to be printed and if False causes '[ Failed ]' to be printed. The special string 'skip' is used to indicate that this has been skipped. 53 @type passed: bool or str 54 @keyword width: The width of the line, excluding the terminal '[ OK ]' or '[ Failed ]'. 55 @type width: int 56 """ 57 58 # Name. 59 sys.stdout.write(name + " ") 60 61 # Dots. 62 for j in xrange(width - len(name)): 63 sys.stdout.write(".") 64 65 # Passed. 66 if passed == True: 67 sys.stdout.write(" %-10s\n" % "[ OK ]") 68 69 # Skipped. 70 elif passed == 'skip': 71 sys.stdout.write(" %-10s\n" % "[ Skipped ]") 72 73 # Failed. 74 else: 75 sys.stdout.write(" %-10s\n" % "[ Failed ]")
76 77
78 -def title(text):
79 """Function for printing the titles. 80 81 @param text: The text of the title to be printed. 82 @type text: str 83 """ 84 85 # The width of the title string. 86 width = len(text) + 4 87 88 # Top spacing. 89 sys.stdout.write("\n\n\n\n") 90 91 # Top bar. 92 sys.stdout.write("#" * width) 93 sys.stdout.write("\n") 94 95 # Text. 96 sys.stdout.write("# %s #\n" % text) 97 98 # Bottom bar. 99 sys.stdout.write("#" * width) 100 101 # Spacing. 102 sys.stdout.write("\n\n\n")
103