~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: 2010-01-07 17:02:44 UTC
  • mfrom: (4934.1.14 2.1.0rc1-set-mtime)
  • Revision ID: pqm@pqm.ubuntu.com-20100107170244-3cgdapvuokgf8l42
(jam,
        gz) (bug #488724) Set the mtime of files touched in a TreeTransform.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
import re
22
22
import time
23
23
 
24
 
from StringIO import StringIO
25
 
 
26
24
from bzrlib import (
27
25
    errors,
28
 
    remote,
29
 
    repository,
30
26
    tests,
31
27
    ui as _mod_ui,
32
28
    )
128
124
        finally:
129
125
            pb.finished()
130
126
 
 
127
    def test_progress_nested(self):
 
128
        # test factory based nested and popping.
 
129
        ui = _mod_ui_text.TextUIFactory(None, None, None)
 
130
        pb1 = ui.nested_progress_bar()
 
131
        pb2 = ui.nested_progress_bar()
 
132
        # You do get a warning if the outermost progress bar wasn't finished
 
133
        # first - it's not clear if this is really useful or if it should just
 
134
        # become orphaned -- mbp 20090120
 
135
        warnings, _ = self.callCatchWarnings(pb1.finished)
 
136
        if len(warnings) != 1:
 
137
            self.fail("unexpected warnings: %r" % (warnings,))
 
138
        pb2.finished()
 
139
        pb1.finished()
 
140
 
131
141
    def test_text_ui_get_boolean(self):
132
142
        stdin = tests.StringIOWrapper("y\n" # True
133
143
                                      "n\n" # False
238
248
        finally:
239
249
            pb.finished()
240
250
 
241
 
    def test_quietness(self):
242
 
        os.environ['BZR_PROGRESS_BAR'] = 'text'
243
 
        ui_factory = _mod_ui_text.TextUIFactory(None,
244
 
            test_progress._TTYStringIO(),
245
 
            test_progress._TTYStringIO())
246
 
        self.assertIsInstance(ui_factory._progress_view,
247
 
            _mod_ui_text.TextProgressView)
248
 
        ui_factory.be_quiet(True)
249
 
        self.assertIsInstance(ui_factory._progress_view,
250
 
            _mod_ui_text.NullProgressView)
251
 
 
252
 
    def test_text_ui_show_user_warning(self):
253
 
        from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
254
 
        from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack5
255
 
        err = StringIO()
256
 
        out = StringIO()
257
 
        ui = tests.TextUIFactory(stdin=None, stdout=out, stderr=err)
258
 
        remote_fmt = remote.RemoteRepositoryFormat()
259
 
        remote_fmt._network_name = RepositoryFormatKnitPack5().network_name()
260
 
        ui.show_user_warning('cross_format_fetch', from_format=RepositoryFormat2a(),
261
 
            to_format=remote_fmt)
262
 
        self.assertEquals('', out.getvalue())
263
 
        self.assertEquals("Doing on-the-fly conversion from RepositoryFormat2a() to "
264
 
            "RemoteRepositoryFormat(_network_name='Bazaar RepositoryFormatKnitPack5 "
265
 
            "(bzr 1.6)\\n').\nThis may take some time. Upgrade the repositories to "
266
 
            "the same format for better performance.\n",
267
 
            err.getvalue())
268
 
        # and now with it suppressed please
269
 
        err = StringIO()
270
 
        out = StringIO()
271
 
        ui = tests.TextUIFactory(stdin=None, stdout=out, stderr=err)
272
 
        ui.suppressed_warnings.add('cross_format_fetch')
273
 
        ui.show_user_warning('cross_format_fetch', from_format=RepositoryFormat2a(),
274
 
            to_format=remote_fmt)
275
 
        self.assertEquals('', out.getvalue())
276
 
        self.assertEquals('', err.getvalue())
277
 
 
278
251
 
279
252
class TestTextUIOutputStream(tests.TestCase):
280
253
    """Tests for output stream that synchronizes with progress bar."""