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

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

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

revision 1219 by bh, Mon Jun 16 17:42:54 2003 UTC revision 2079 by bh, Fri Feb 20 14:29:13 2004 UTC
# Line 1  Line 1 
1  # Copyright (c) 2002, 2003 by Intevation GmbH  # Copyright (c) 2002, 2003, 2004 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 11  Main entry point for the Thuban test sui Line 11  Main entry point for the Thuban test sui
11  Just run this file as a python script to execute all tests  Just run this file as a python script to execute all tests
12  """  """
13    
14    __version__ = "$Revision$"
15    # $Source$
16    # $Id$
17    
18    import os
19    
20    # It should be possible to run the Thuban testsuite without an X
21    # connection, so we remove the DISPLAY environment variable which should
22    # lead to an error if the wxGTK module is imported accidentally. The
23    # DISPLAY variable is not always set so we catch and ignore the KeyError
24    try:
25        del os.environ["DISPLAY"]
26    except KeyError:
27        pass
28    
29  import os, sys  import sys
30  import warnings  import warnings
31  import unittest  import unittest
32    import getopt
33    
34  import support  import support
35  support.initthuban()  support.initthuban()
36  import Thuban.Lib.connector  import Thuban.Lib.connector
37    
38    def find_test_modules(dirname, package = None):
39        """Return a list the names of the test modules in the directory dirname
40    
41        The return value is a list of names that can be passed to
42        unittest.defaultTestLoader.loadTestsFromNames.  Each name of the
43        list is the name of a pure python module, one for each file in
44        dirname that starts with 'test'.
45    
46        The optional parameter package should be the name of the python
47        package whose directory is dirname.  If package is given all names
48        in the returned list will be prefixed with package and a dot.
49        """
50        if package:
51            prefix = package + "."
52        else:
53            prefix = ""
54    
55        return [prefix + name[:-3]
56                for name in os.listdir(dirname)
57                    if name[:4] == "test" and name[-3:] == ".py"]
58    
59    
60  def main():  def main():
61      """Run all the tests in the Thuban test suite"""      """Run all the tests in the Thuban test suite"""
62    
# Line 35  def main(): Line 72  def main():
72      warnings.filterwarnings("error", "The Layer attribute.*is deprecated",      warnings.filterwarnings("error", "The Layer attribute.*is deprecated",
73                              DeprecationWarning)                              DeprecationWarning)
74    
75      # Usage of the old table interface. This old interface is still used      verbosity = 1
     # by the test_table.py module which calls filterwarnings too to  
     # ignore the warnings issued by its own intended use of the old  
     # interface.  
     warnings.filterwarnings("error", ".*old table interface.*",  
                             DeprecationWarning)  
   
76    
77      # All Python files starting with test in the current directory      opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])
78      # contain test cases.      for optchar, value in opts:
79      # FIXME: It should be possible to run runtests.py even when not in          if optchar in ("-v", "--verbose"):
80      # the test directory              verbosity = 2
81      files = os.listdir(os.curdir)          else:
82      names = []              print>>sys.stderr, "Unknown option", optchar
83      for file in files:  
84          if file[:4] == "test" and file[-3:] == ".py":      # Build the list of test names.  If names were given on the command
85              names.append(file[:-3])      # line, run exactly those.  Othwerwise build a default list of
86        # names.
87        if args:
88            names = args
89        else:
90            # All Python files starting with 'test' in the current directory
91            # and some directories in Extensions contain test cases.
92            # FIXME: It should be possible to run runtests.py even when not in
93            # the test directory
94            names = find_test_modules(".")
95            names += find_test_modules("../Extensions/svgexport/test",
96                                       "Extensions.svgexport.test")
97    
98      suite = unittest.defaultTestLoader.loadTestsFromNames(names)      suite = unittest.defaultTestLoader.loadTestsFromNames(names)
99      runner = unittest.TextTestRunner(verbosity = 2)      runner = support.ThubanTestRunner(verbosity = verbosity)
100      result = runner.run(suite)      result = support.execute_as_testsuite(runner.run, suite)
   
     support.print_garbage_information()  
101    
102      sys.exit(not result.wasSuccessful())      sys.exit(not result.wasSuccessful())
103    

Legend:
Removed from v.1219  
changed lines
  Added in v.2079

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26