363
364
self.pb.show_bar = False
365
366
def report_starting(self):
366
self.pb.update('[test 0/%d] starting...' % (self.num_tests))
367
self.pb.update('[test 0/%d] Starting' % (self.num_tests))
368
369
def _progress_prefix_text(self):
369
370
# the longer this text, the less space we have to show the test
428
429
"""test cannot be run because feature is missing."""
430
431
def report_cleaning_up(self):
431
self.pb.update('cleaning up...')
432
self.pb.update('Cleaning up')
433
434
def finished(self):
434
435
if not self._supplied_pb:
763
764
def __init__(self, methodName='testMethod'):
764
765
super(TestCase, self).__init__(methodName)
765
766
self._cleanups = []
767
self._bzr_test_setUp_run = False
768
self._bzr_test_tearDown_run = False
768
771
unittest.TestCase.setUp(self)
772
self._bzr_test_setUp_run = True
769
773
self._cleanEnvironment()
770
774
self._silenceUI()
771
775
self._startLogFile()
815
819
def _clear_hooks(self):
816
820
# prevent hooks affecting tests
818
import bzrlib.smart.client
819
import bzrlib.smart.server
820
self._preserved_hooks = {
821
bzrlib.branch.Branch: bzrlib.branch.Branch.hooks,
822
bzrlib.mutabletree.MutableTree: bzrlib.mutabletree.MutableTree.hooks,
823
bzrlib.smart.client._SmartClient: bzrlib.smart.client._SmartClient.hooks,
824
bzrlib.smart.server.SmartTCPServer: bzrlib.smart.server.SmartTCPServer.hooks,
825
bzrlib.commands.Command: bzrlib.commands.Command.hooks,
821
self._preserved_hooks = {}
822
for key, factory in hooks.known_hooks.items():
823
parent, name = hooks.known_hooks_key_to_parent_and_attribute(key)
824
current_hooks = hooks.known_hooks_key_to_object(key)
825
self._preserved_hooks[parent] = (name, current_hooks)
827
826
self.addCleanup(self._restoreHooks)
828
# reset all hooks to an empty instance of the appropriate type
829
bzrlib.branch.Branch.hooks = bzrlib.branch.BranchHooks()
830
bzrlib.smart.client._SmartClient.hooks = bzrlib.smart.client.SmartClientHooks()
831
bzrlib.smart.server.SmartTCPServer.hooks = bzrlib.smart.server.SmartServerHooks()
832
bzrlib.commands.Command.hooks = bzrlib.commands.CommandHooks()
827
for key, factory in hooks.known_hooks.items():
828
parent, name = hooks.known_hooks_key_to_parent_and_attribute(key)
829
setattr(parent, name, factory())
834
831
def _silenceUI(self):
835
832
"""Turn off UI for duration of test"""
908
905
self.assertEqual(expected.st_ino, actual.st_ino)
909
906
self.assertEqual(expected.st_mode, actual.st_mode)
908
def assertLength(self, length, obj_with_len):
909
"""Assert that obj_with_len is of length length."""
910
if len(obj_with_len) != length:
911
self.fail("Incorrect length: wanted %d, got %d for %r" % (
912
length, len(obj_with_len), obj_with_len))
911
914
def assertPositive(self, val):
912
915
"""Assert that val is greater than 0."""
913
916
self.assertTrue(val > 0, 'expected a positive value, but got %s' % val)
1288
1291
osutils.set_or_unset_env(name, value)
1290
1293
def _restoreHooks(self):
1291
for klass, hooks in self._preserved_hooks.items():
1292
setattr(klass, 'hooks', hooks)
1294
for klass, (name, hooks) in self._preserved_hooks.items():
1295
setattr(klass, name, hooks)
1294
1297
def knownFailure(self, reason):
1295
1298
"""This test has failed for some known reason."""
2113
2125
made_control = self.make_bzrdir(relpath, format=format)
2114
2126
return made_control.create_repository(shared=shared)
2128
def make_smart_server(self, path):
2129
smart_server = server.SmartTCPServer_for_testing()
2130
smart_server.setUp(self.get_server())
2131
remote_transport = get_transport(smart_server.get_url()).clone(path)
2132
self.addCleanup(smart_server.tearDown)
2133
return remote_transport
2116
2135
def make_branch_and_memory_tree(self, relpath, format=None):
2117
2136
"""Create a branch on the default transport and a MemoryTree for it."""
2118
2137
b = self.make_branch(relpath, format=format)
2918
2937
'bzrlib.tests.test_bundle',
2919
2938
'bzrlib.tests.test_bzrdir',
2920
2939
'bzrlib.tests.test_cache_utf8',
2940
'bzrlib.tests.test_clean_tree',
2921
2941
'bzrlib.tests.test_chunk_writer',
2922
2942
'bzrlib.tests.test__chunks_to_lines',
2923
2943
'bzrlib.tests.test_commands',