~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/__init__.py

'bzr selftest' now shows a progress bar with the number of tests, and 
progress made. 'make check' shows tests in -v mode, to be more useful
for the PQM status window. (Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
rather starts again from the run_bzr function.
24
24
"""
25
25
 
 
26
import sys
 
27
 
26
28
from bzrlib.tests import (
27
29
                          _load_module_by_name,
28
30
                          TestCaseWithTransport,
92
94
            return self.run_bzr_captured(args, retcode=retcode)
93
95
 
94
96
 
95
 
class TestUIFactory(ui.UIFactory):
 
97
class TestUIFactory(ui.CLIUIFactory):
96
98
    """A UI Factory for testing - hide the progress bar but emit note()s."""
97
99
 
 
100
    def __init__(self,
 
101
                 stdout=None,
 
102
                 stderr=None):
 
103
        super(TestUIFactory, self).__init__()
 
104
        if stdout is None:
 
105
            self.stdout = sys.stdout
 
106
        else:
 
107
            self.stdout = stdout
 
108
        if stderr is None:
 
109
            self.stderr = sys.stderr
 
110
        else:
 
111
            self.stderr = stderr
 
112
 
98
113
    def clear(self):
99
114
        """See progress.ProgressBar.clear()."""
100
115
 
 
116
    def clear_term(self):
 
117
        """See progress.ProgressBar.clear_term()."""
 
118
 
101
119
    def finished(self):
102
120
        """See progress.ProgressBar.finished()."""
103
121
 
104
122
    def note(self, fmt_string, *args, **kwargs):
105
123
        """See progress.ProgressBar.note()."""
106
 
        print fmt_string % args
 
124
        self.stdout.write((fmt_string + "\n") % args)
107
125
 
108
126
    def progress_bar(self):
109
127
        return self