~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to test/package_unittest.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
# Author: Garth Kidd
4
4
# Contact: garth@deadlybloodyserious.com
5
 
# Revision: $Revision: 1.6 $
6
 
# Date: $Date: 2002/10/09 00:51:52 $
 
5
# Revision: $Revision: 2454 $
 
6
# Date: $Date: 2004-07-25 13:29:43 +0200 (Sun, 25 Jul 2004) $
7
7
# Copyright: This module has been placed in the public domain.
8
8
 
9
9
"""
66
66
        if len(args) != 0:
67
67
            usageExit("No command-line arguments supported yet.")
68
68
    except getopt.error, msg:
69
 
        self.usageExit(msg)
 
69
        usageExit(msg)
70
70
 
71
71
def loadTestModules(path, name='', packages=None):
72
72
    """
99
99
    for mod in testModules:
100
100
        if debug:
101
101
            print >>sys.stderr, "importing %s" % mod
102
 
        module = import_module(mod)
103
 
        # if there's a suite defined, incorporate its contents
104
102
        try:
105
 
            suite = getattr(module, 'suite')
106
 
        except AttributeError:
107
 
            # Look for individual tests
108
 
            moduleTests = testLoader.loadTestsFromModule(module)
109
 
            # unittest.TestSuite.addTests() doesn't work as advertised,
110
 
            # as it can't load tests from another TestSuite, so we have
111
 
            # to cheat:
112
 
            testSuite.addTest(moduleTests)
113
 
            continue
114
 
        if type(suite) == types.FunctionType:
115
 
            testSuite.addTest(suite())
116
 
        elif type(suite) == types.InstanceType \
117
 
              and isinstance(suite, unittest.TestSuite):
118
 
            testSuite.addTest(suite)
 
103
            module = import_module(mod)
 
104
        except ImportError:
 
105
            print >>sys.stderr, "ERROR: Can't import %s, skipping its tests:" % mod
 
106
            sys.excepthook(*sys.exc_info())
119
107
        else:
120
 
            raise AssertionError, "don't understand suite (%s)" % mod
 
108
            # if there's a suite defined, incorporate its contents
 
109
            try:
 
110
                suite = getattr(module, 'suite')
 
111
            except AttributeError:
 
112
                # Look for individual tests
 
113
                moduleTests = testLoader.loadTestsFromModule(module)
 
114
                # unittest.TestSuite.addTests() doesn't work as advertised,
 
115
                # as it can't load tests from another TestSuite, so we have
 
116
                # to cheat:
 
117
                testSuite.addTest(moduleTests)
 
118
                continue
 
119
            if type(suite) == types.FunctionType:
 
120
                testSuite.addTest(suite())
 
121
            elif type(suite) == types.InstanceType \
 
122
                  and isinstance(suite, unittest.TestSuite):
 
123
                testSuite.addTest(suite)
 
124
            else:
 
125
                raise AssertionError, "don't understand suite (%s)" % mod
121
126
    sys.path.pop(0)
122
127
    return testSuite
123
128