/[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 1605 by bh, Tue Aug 19 11:00:40 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    import postgissupport
21    
22    
23  def thuban_dir():  def thuban_dir():
24      """Return the directory containing the Thuban package"""      """Return the directory containing the Thuban package"""
# Line 98  class ThubanTestResult(unittest._TextTes Line 102  class ThubanTestResult(unittest._TextTes
102                  self.stream.writeln()                  self.stream.writeln()
103              self.stream.writeln("Skipped tests:")              self.stream.writeln("Skipped tests:")
104              for reason, tests in self.skipped_tests.items():              for reason, tests in self.skipped_tests.items():
105                  self.stream.writeln("%s:" % reason)                  self.stream.writeln("  %s:" % reason)
106                  for test in tests:                  for test in tests:
107                      self.stream.writeln("    " + test.id())                      self.stream.writeln("    " + test.id())
108          unittest._TextTestResult.printErrors(self)          unittest._TextTestResult.printErrors(self)
# Line 124  class ThubanTestProgram(unittest.TestPro Line 128  class ThubanTestProgram(unittest.TestPro
128          unittest.TestProgram.runTests(self)          unittest.TestProgram.runTests(self)
129    
130    
131  def run_tests():  def execute_as_testsuite(callable, *args, **kw):
132      """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
133    
134      After calling unittest.main, run the garbage collector and print      Return watever callable returns.
135      uncollected objects. Also print any un-unsubscribed messages.  
136        This is a helper function for run_tests and runtests.py. Call
137        callable in a try-finally block and run some cleanup and print some
138        additional information in the finally block.
139    
140        The additionaly information include:
141    
142         - A list of uncollected objects (after an explicit garbage
143           collector call)
144    
145         - any unsubscribed messages
146      """      """
147      try:      try:
148          ThubanTestProgram()          return callable(*args, **kw)
149      finally:      finally:
150          # This has to be in a finally clause because unittest.main()          # This has to be in a finally clause because unittest.main()
151          # 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
152          # an appropriate exit code          # an appropriate exit code
153    
154            # Shutdown the postgis server if it's running
155            try:
156                postgissupport.shutdown_test_server()
157            except:
158                traceback.print_exc()
159    
160            # Print additional information
161          print_additional_summary()          print_additional_summary()
162    
163    def run_tests():
164        """Frontend for unittest.main that prints some additional debug information
165    
166        After calling unittest.main, run the garbage collector and print
167        uncollected objects. Also print any un-unsubscribed messages.
168        """
169        execute_as_testsuite(ThubanTestProgram)
170    
171    
172  def print_additional_summary():  def print_additional_summary():
173      """Print some additional summary information after tests have been run"""      """Print some additional summary information after tests have been run"""
174      print_garbage_information()      print_garbage_information()

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26