/[thuban]/branches/WIP-pyshapelib-bramz/test/support.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/test/support.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1574 by bh, Mon Aug 11 12:07:47 2003 UTC revision 1601 by bh, Mon Aug 18 17:22:07 2003 UTC
# Line 15  __version__ = "$Revision$" Line 15  __version__ = "$Revision$"
15    
16  import os, sys  import os, sys
17  import unittest  import unittest
18    import traceback
19    
20  def thuban_dir():  def thuban_dir():
21      """Return the directory containing the Thuban package"""      """Return the directory containing the Thuban package"""
# Line 98  class ThubanTestResult(unittest._TextTes Line 99  class ThubanTestResult(unittest._TextTes
99                  self.stream.writeln()                  self.stream.writeln()
100              self.stream.writeln("Skipped tests:")              self.stream.writeln("Skipped tests:")
101              for reason, tests in self.skipped_tests.items():              for reason, tests in self.skipped_tests.items():
102                  self.stream.writeln("%s:" % reason)                  self.stream.writeln("  %s:" % reason)
103                  for test in tests:                  for test in tests:
104                      self.stream.writeln("    " + test.id())                      self.stream.writeln("    " + test.id())
105          unittest._TextTestResult.printErrors(self)          unittest._TextTestResult.printErrors(self)
# Line 124  class ThubanTestProgram(unittest.TestPro Line 125  class ThubanTestProgram(unittest.TestPro
125          unittest.TestProgram.runTests(self)          unittest.TestProgram.runTests(self)
126    
127    
128  def run_tests():  def execute_as_testsuite(callable, *args, **kw):
129      """Frontend for unittest.main that prints some additional debug information      """Call callable  with args as if it were the entry point to the test suite
130    
131      After calling unittest.main, run the garbage collector and print      Return watever callable returns.
132      uncollected objects. Also print any un-unsubscribed messages.  
133        This is a helper function for run_tests and runtests.py. Call
134        callable in a try-finally block and run some cleanup and print some
135        additional information in the finally block.
136    
137        The additionaly information include:
138    
139         - A list of uncollected objects (after an explicit garbage
140           collector call)
141    
142         - any unsubscribed messages
143      """      """
144      try:      try:
145          ThubanTestProgram()          return callable(*args, **kw)
146      finally:      finally:
147          # This has to be in a finally clause because unittest.main()          # This has to be in a finally clause because unittest.main()
148          # ends with a sys.exit to make sure that the process exits with          # ends with a sys.exit to make sure that the process exits with
149          # an appropriate exit code          # an appropriate exit code
150    
151            # Print additional information
152          print_additional_summary()          print_additional_summary()
153    
154    def run_tests():
155        """Frontend for unittest.main that prints some additional debug information
156    
157        After calling unittest.main, run the garbage collector and print
158        uncollected objects. Also print any un-unsubscribed messages.
159        """
160        execute_as_testsuite(ThubanTestProgram)
161    
162    
163  def print_additional_summary():  def print_additional_summary():
164      """Print some additional summary information after tests have been run"""      """Print some additional summary information after tests have been run"""
165      print_garbage_information()      print_garbage_information()

Legend:
Removed from v.1574  
changed lines
  Added in v.1601

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26