89
89
except ImportError:
90
90
# lsprof not available
92
from bzrlib.merge import merge_inner
93
92
import bzrlib.merge3
94
93
import bzrlib.plugin
95
from bzrlib.smart import client, request, server
94
from bzrlib.smart import client, request
96
95
import bzrlib.store
97
96
from bzrlib import symbol_versioning
98
97
from bzrlib.symbol_versioning import (
116
115
from bzrlib.ui import NullProgressView
117
116
from bzrlib.ui.text import TextUIFactory
118
117
import bzrlib.version_info_formats.format_custom
119
from bzrlib.workingtree import WorkingTree, WorkingTreeFormat2
121
119
# Mark this python module as being part of the implementation
122
120
# of unittest: this gives us better tracebacks where the last
3356
class ForwardingResult(unittest.TestResult):
3358
def __init__(self, target):
3359
unittest.TestResult.__init__(self)
3360
self.result = target
3362
def startTest(self, test):
3363
self.result.startTest(test)
3365
def stopTest(self, test):
3366
self.result.stopTest(test)
3368
def startTestRun(self):
3369
self.result.startTestRun()
3371
def stopTestRun(self):
3372
self.result.stopTestRun()
3374
def addSkip(self, test, reason):
3375
self.result.addSkip(test, reason)
3377
def addSuccess(self, test):
3378
self.result.addSuccess(test)
3380
def addError(self, test, err):
3381
self.result.addError(test, err)
3383
def addFailure(self, test, err):
3384
self.result.addFailure(test, err)
3385
ForwardingResult = testtools.ExtendedToOriginalDecorator
3388
class ProfileResult(ForwardingResult):
3354
class ProfileResult(testtools.ExtendedToOriginalDecorator):
3389
3355
"""Generate profiling data for all activity between start and success.
3391
3357
The profile data is appended to the test's _benchcalls attribute and can
3403
3369
# unavoidably fail.
3404
3370
bzrlib.lsprof.BzrProfiler.profiler_block = 0
3405
3371
self.profiler.start()
3406
ForwardingResult.startTest(self, test)
3372
testtools.ExtendedToOriginalDecorator.startTest(self, test)
3408
3374
def addSuccess(self, test):
3409
3375
stats = self.profiler.stop()
3413
3379
test._benchcalls = []
3414
3380
calls = test._benchcalls
3415
3381
calls.append(((test.id(), "", ""), stats))
3416
ForwardingResult.addSuccess(self, test)
3382
testtools.ExtendedToOriginalDecorator.addSuccess(self, test)
3418
3384
def stopTest(self, test):
3419
ForwardingResult.stopTest(self, test)
3385
testtools.ExtendedToOriginalDecorator.stopTest(self, test)
3420
3386
self.profiler = None