681
681
self.assertEqual(url, t.clone('..').base)
684
class MockProgress(progress._BaseProgressBar):
685
"""Progress-bar standin that records calls.
687
Useful for testing pb using code.
691
progress._BaseProgressBar.__init__(self)
695
self.calls.append(('tick',))
697
def update(self, msg=None, current=None, total=None):
698
self.calls.append(('update', msg, current, total))
701
self.calls.append(('clear',))
703
def note(self, msg, *args):
704
self.calls.append(('note', msg, args))
707
684
class TestTestResult(tests.TestCase):
709
686
def check_timing(self, test_case, expected_re):
862
839
self.assertEqual(lines[1], ' foo')
863
840
self.assertEqual(2, len(lines))
865
def test_text_report_known_failure(self):
866
# text test output formatting
868
result = bzrlib.tests.TextTestResult(
874
test = self.get_passing_test()
875
# this seeds the state to handle reporting the test.
876
result.startTest(test)
877
# the err parameter has the shape:
878
# (class, exception object, traceback)
879
# KnownFailures dont get their tracebacks shown though, so we
881
err = (tests.KnownFailure, tests.KnownFailure('foo'), None)
882
result.report_known_failure(test, err)
885
('update', '[1 in 0s] passing_test', None, None),
886
('note', 'XFAIL: %s\n%s\n', ('passing_test', err[1]))
889
# known_failures should be printed in the summary, so if we run a test
890
# after there are some known failures, the update prefix should match
892
result.known_failure_count = 3
896
('update', '[2 in 0s] passing_test', None, None),
900
842
def get_passing_test(self):
901
843
"""Return a test object that can't be run usefully."""
902
844
def passing_test():
947
889
self.assertEqual(lines, ['NODEP 0ms',
948
890
" The feature 'Feature' is not available."])
950
def test_text_report_unsupported(self):
951
# text test output formatting
953
result = bzrlib.tests.TextTestResult(
959
test = self.get_passing_test()
960
feature = tests.Feature()
961
# this seeds the state to handle reporting the test.
962
result.startTest(test)
963
result.report_unsupported(test, feature)
964
# no output on unsupported features
966
[('update', '[1 in 0s] passing_test', None, None)
969
# the number of missing features should be printed in the progress
970
# summary, so check for that.
971
result.unsupported = {'foo':0, 'bar':0}
975
('update', '[2 in 0s, 2 missing] passing_test', None, None),
979
892
def test_unavailable_exception(self):
980
893
"""An UnavailableFeature being raised should invoke addNotSupported."""
981
894
class InstrumentedTestResult(tests.ExtendedTestResult):