~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-11 17:50:37 UTC
  • mfrom: (1704.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060511175037-f66b84c6a9fc4c12
Merge selftest uses progress-bars. (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