750
751
revision_id = workingtree.get_parent_ids()[0]
751
752
self.assertEndsWith(output_string.rstrip(), revision_id)
754
def test_success_log_deleted(self):
755
"""Successful tests have their log deleted"""
757
class LogTester(TestCase):
759
def test_success(self):
760
self.log('this will be removed\n')
762
sio = cStringIO.StringIO()
763
runner = TextTestRunner(stream=sio)
764
test = LogTester('test_success')
765
result = self.run_test_runner(runner, test)
767
log = test._get_log()
768
self.assertEqual("DELETED log file to reduce memory footprint", log)
769
self.assertEqual('', test._log_contents)
770
self.assertIs(None, test._log_file_name)
772
def test_fail_log_kept(self):
773
"""Failed tests have their log kept"""
775
class LogTester(TestCase):
778
self.log('this will be kept\n')
779
self.fail('this test fails')
781
sio = cStringIO.StringIO()
782
runner = TextTestRunner(stream=sio)
783
test = LogTester('test_fail')
784
result = self.run_test_runner(runner, test)
786
text = sio.getvalue()
787
self.assertContainsRe(text, 'this will be kept')
788
self.assertContainsRe(text, 'this test fails')
790
log = test._get_log()
791
self.assertContainsRe(log, 'this will be kept')
792
self.assertEqual(log, test._log_contents)
794
def test_error_log_kept(self):
795
"""Tests with errors have their log kept"""
797
class LogTester(TestCase):
799
def test_error(self):
800
self.log('this will be kept\n')
801
raise ValueError('random exception raised')
803
sio = cStringIO.StringIO()
804
runner = TextTestRunner(stream=sio)
805
test = LogTester('test_error')
806
result = self.run_test_runner(runner, test)
808
text = sio.getvalue()
809
self.assertContainsRe(text, 'this will be kept')
810
self.assertContainsRe(text, 'random exception raised')
812
log = test._get_log()
813
self.assertContainsRe(log, 'this will be kept')
814
self.assertEqual(log, test._log_contents)
754
817
class TestTestCase(TestCase):
755
818
"""Tests that test the core bzrlib TestCase."""