~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Martin Pool
  • Date: 2008-12-16 05:51:24 UTC
  • mto: (3882.7.11 progress)
  • mto: This revision was merged to the branch mainline in revision 3940.
  • Revision ID: mbp@sourcefrog.net-20081216055124-uxx9245lbuef07le
All UI factories should support note()

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
    def test_progress_note(self):
102
102
        stderr = StringIO()
103
103
        stdout = StringIO()
104
 
        ui_factory = TextUIFactory(bar_type=TTYProgressBar)
 
104
        ui_factory = TextUIFactory(bar_type=TTYProgressBar, stderr=stderr,
 
105
                stdout=stdout)
105
106
        pb = ui_factory.nested_progress_bar()
106
107
        try:
107
 
            pb.to_messages_file = stdout
108
 
            ui_factory._progress_bar_stack.bottom().to_file = stderr
109
108
            result = pb.note('t')
110
109
            self.assertEqual(None, result)
111
110
            self.assertEqual("t\n", stdout.getvalue())
122
121
        # The PQM redirects the output to a file, so it
123
122
        # defaults to creating a Dots progress bar. we
124
123
        # need to force it to believe we are a TTY
125
 
        ui_factory = TextUIFactory(bar_type=TTYProgressBar)
 
124
        ui_factory = TextUIFactory(bar_type=TTYProgressBar,
 
125
            stdout=stdout, stderr=stderr)
126
126
        pb = ui_factory.nested_progress_bar()
127
127
        try:
128
 
            pb.to_messages_file = stdout
129
 
            ui_factory._progress_bar_stack.bottom().to_file = stderr
130
128
            # Create a progress update that isn't throttled
131
129
            pb.start_time -= 10
132
130
            pb.update('x', 1, 1)
145
143
        ui = TextUIFactory()
146
144
        pb1 = ui.nested_progress_bar()
147
145
        pb2 = ui.nested_progress_bar()
148
 
        self.assertRaises(errors.MissingProgressBarFinish, pb1.finished)
 
146
        self.assertRaises((AssertionError, errors.MissingProgressBarFinish),
 
147
            pb1.finished)
149
148
        pb2.finished()
150
149
        pb1.finished()
151
150