~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-09 06:37:40 UTC
  • mfrom: (4792.8.16 progress-output)
  • Revision ID: pqm@pqm.ubuntu.com-20091209063740-orfojzx53lbt29ey
(mbp) progress bars automatically synchronize with other terminal
        output

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    NullProgressView,
51
51
    TextProgressView,
52
52
    TextUIFactory,
 
53
    TextUIOutputStream,
53
54
    )
54
55
 
55
56
 
253
254
            pb.finished()
254
255
 
255
256
 
 
257
class TestTextUIOutputStream(TestCase):
 
258
    """Tests for output stream that synchronizes with progress bar."""
 
259
 
 
260
    def test_output_clears_terminal(self):
 
261
        stdout = StringIO()
 
262
        stderr = StringIO()
 
263
        clear_calls = []
 
264
 
 
265
        uif = TextUIFactory(None, stdout, stderr)
 
266
        uif.clear_term = lambda: clear_calls.append('clear')
 
267
 
 
268
        stream = TextUIOutputStream(uif, uif.stdout)
 
269
        stream.write("Hello world!\n")
 
270
        stream.write("there's more...\n")
 
271
        stream.writelines(["1\n", "2\n", "3\n"])
 
272
        
 
273
        self.assertEqual(stdout.getvalue(),
 
274
            "Hello world!\n"
 
275
            "there's more...\n"
 
276
            "1\n2\n3\n")
 
277
        self.assertEqual(['clear', 'clear', 'clear'],
 
278
            clear_calls)
 
279
 
 
280
        stream.flush()
 
281
 
 
282
 
256
283
class UITests(tests.TestCase):
257
284
 
258
285
    def test_progress_construction(self):