~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Martin Pool
  • Date: 2009-11-15 22:10:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4880.
  • Revision ID: mbp@sourcefrog.net-20091115221030-1jfiufckgs8t2whs
Add TextUIOutputStream coordinated with progress view

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
        
 
272
        self.assertEqual(stdout.getvalue(),
 
273
            "Hello world!\n"
 
274
            "there's more...\n")
 
275
        self.assertEqual(['clear', 'clear'],
 
276
            clear_calls)
 
277
 
 
278
 
 
279
 
256
280
class UITests(tests.TestCase):
257
281
 
258
282
    def test_progress_construction(self):