~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testsweet.py

  • Committer: Martin Pool
  • Date: 2005-09-22 13:32:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050922133202-347cfd35d2941dd5
- simple weave-based annotate code (not complete)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    """Indicates that a test was intentionally skipped, rather than failing."""
56
56
    # XXX: Not used yet
57
57
 
 
58
 
 
59
 
58
60
class EarlyStoppingTestResultAdapter(object):
59
61
    """An adapter for TestResult to stop at the first first failure or error"""
60
62
 
88
90
    def startTest(self, test):
89
91
        unittest.TestResult.startTest(self, test)
90
92
        # TODO: Maybe show test.shortDescription somewhere?
91
 
        what = test.shortDescription() or test.id()        
 
93
        what = test.id()
 
94
        # python2.3 has the bad habit of just "runit" for doctests
 
95
        if what == 'runit':
 
96
            what = test.shortDescription()
92
97
        if self.showAll:
93
 
            self.stream.write('%-70.70s' % what)
 
98
            self.stream.write('%-60.60s' % what)
94
99
        self.stream.flush()
95
100
 
96
101
    def addError(self, test, err):
113
118
        for test, err in errors:
114
119
            self.stream.writeln(self.separator1)
115
120
            self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
 
121
            self.stream.writeln(self.separator2)
 
122
            self.stream.writeln("%s" % err)
116
123
            if hasattr(test, '_get_log'):
117
124
                self.stream.writeln()
118
125
                self.stream.writeln('log from this test:')
119
126
                print >>self.stream, test._get_log()
120
 
            self.stream.writeln(self.separator2)
121
 
            self.stream.writeln("%s" % err)
122
127
 
123
128
 
124
129
class TextTestRunner(unittest.TextTestRunner):
168
173
    # but only a little. Folk not using our testrunner will
169
174
    # have to delete their temp directories themselves.
170
175
    if result.wasSuccessful():
171
 
        if TestCaseInTempDir.TEST_ROOT is not None:
 
176
        if TestCaseInTempDir.TEST_ROOT:
172
177
            shutil.rmtree(TestCaseInTempDir.TEST_ROOT) 
173
178
    else:
174
179
        print "Failed tests working directories are in '%s'\n" % TestCaseInTempDir.TEST_ROOT