~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Martin Pool
  • Date: 2006-08-16 02:53:40 UTC
  • mto: This revision was merged to the branch mainline in revision 1928.
  • Revision ID: mbp@sourcefrog.net-20060816025340-5149ec9455c00ba3
Improved reporting of bzrlib revision_id
Use this for bzr --version and in benchmark log

Show diffs side-by-side

added added

removed removed

Lines of Context:
139
139
    
140
140
    def __init__(self, stream, descriptions, verbosity, pb=None,
141
141
                 bench_history=None):
 
142
        """Construct new TestResult.
 
143
 
 
144
        :param bench_history: Optionally, a writable file object to accumulate
 
145
            benchmark results.
 
146
        """
142
147
        unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
143
148
        self.pb = pb
144
149
        if bench_history is not None:
145
 
            # XXX: If there's no branch, what should we do?
146
 
            branch = bzrlib.branch.Branch.open_containing(__file__)[0]
147
 
            revision_id = branch.last_revision()
 
150
            from bzrlib.version import _get_bzr_source_tree
 
151
            src_tree = _get_bzr_source_tree()
 
152
            if src_tree:
 
153
                revision_id = src_tree.last_revision()
 
154
            else:
 
155
                # XXX: If there's no branch, what should we do?
 
156
                revision_id = ''
148
157
            bench_history.write("--date %s %s\n" % (time.time(), revision_id))
149
158
        self._bench_history = bench_history
150
159
    
411
420
 
412
421
class TestSkipped(Exception):
413
422
    """Indicates that a test was intentionally skipped, rather than failing."""
414
 
    # XXX: Not used yet
415
423
 
416
424
 
417
425
class CommandFailed(Exception):
1358
1366
                   'bzrlib.tests.test_upgrade',
1359
1367
                   'bzrlib.tests.test_urlutils',
1360
1368
                   'bzrlib.tests.test_versionedfile',
 
1369
                   'bzrlib.tests.test_version',
1361
1370
                   'bzrlib.tests.test_weave',
1362
1371
                   'bzrlib.tests.test_whitebox',
1363
1372
                   'bzrlib.tests.test_workingtree',