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 (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  import sys 
 24   
 25   
26 -def subtitle(text):
27 """Function for printing the subtitles. 28 29 @param text: The text of the subtitle to be printed. 30 @type text: str 31 """ 32 33 # The width of the subtitle string. 34 width = len(text) + 2 35 36 # Text. 37 sys.stdout.write("# %s\n" % text) 38 39 # Bottom bar. 40 sys.stdout.write("#" * width) 41 42 # Spacing. 43 sys.stdout.write("\n\n")
44 45
46 -def summary_line(name, passed, width=100):
47 """Print a summary line. 48 49 @param name: The name of the test, test category, etc. 50 @type name: str 51 @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. 52 @type passed: bool or str 53 @keyword width: The width of the line, excluding the terminal '[ OK ]' or '[ Failed ]'. 54 @type width: int 55 """ 56 57 # Passed. 58 if passed == True: 59 state = "OK" 60 61 # Skipped. 62 elif passed == 'skip': 63 state = "Skipped" 64 65 # Failed. 66 else: 67 state = "Failed" 68 69 # Dots. 70 dots = '' 71 for j in range(width - len(name) - len(state) - 6): 72 dots += '.' 73 74 # Write out the line. 75 sys.stdout.write("%s %s [ %s ]\n" % (name, dots, state))
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