24
from StringIO import StringIO
26
24
from bzrlib import (
34
29
from bzrlib.symbol_versioning import (
37
from bzrlib.tests import (
32
from bzrlib.tests import test_progress
41
33
from bzrlib.ui import text as _mod_ui_text
44
class TestUIConfiguration(tests.TestCaseWithTransport):
46
def test_output_encoding_configuration(self):
47
enc = fixtures.generate_unicode_encodings().next()
48
config.GlobalConfig().set_user_option('output_encoding',
50
ui = tests.TestUIFactory(stdin=None,
51
stdout=tests.StringIOWrapper(),
52
stderr=tests.StringIOWrapper())
53
os = ui.make_output_stream()
54
self.assertEquals(os.encoding, enc)
57
36
class TestTextUIFactory(tests.TestCase):
59
38
def test_text_factory_ascii_password(self):
266
245
self.assertIsInstance(ui_factory._progress_view,
267
246
_mod_ui_text.NullProgressView)
269
def test_text_ui_show_user_warning(self):
270
from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
271
from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack5
274
ui = tests.TextUIFactory(stdin=None, stdout=out, stderr=err)
275
remote_fmt = remote.RemoteRepositoryFormat()
276
remote_fmt._network_name = RepositoryFormatKnitPack5().network_name()
277
ui.show_user_warning('cross_format_fetch', from_format=RepositoryFormat2a(),
278
to_format=remote_fmt)
279
self.assertEquals('', out.getvalue())
280
self.assertEquals("Doing on-the-fly conversion from RepositoryFormat2a() to "
281
"RemoteRepositoryFormat(_network_name='Bazaar RepositoryFormatKnitPack5 "
282
"(bzr 1.6)\\n').\nThis may take some time. Upgrade the repositories to "
283
"the same format for better performance.\n",
285
# and now with it suppressed please
288
ui = tests.TextUIFactory(stdin=None, stdout=out, stderr=err)
289
ui.suppressed_warnings.add('cross_format_fetch')
290
ui.show_user_warning('cross_format_fetch', from_format=RepositoryFormat2a(),
291
to_format=remote_fmt)
292
self.assertEquals('', out.getvalue())
293
self.assertEquals('', err.getvalue())
296
249
class TestTextUIOutputStream(tests.TestCase):
297
250
"""Tests for output stream that synchronizes with progress bar."""
403
356
def test_test_ui_factory_progress(self):
404
357
# there's no output; we just want to make sure this doesn't crash -
405
# see https://bugs.launchpad.net/bzr/+bug/408201
358
# see https://bugs.edge.launchpad.net/bzr/+bug/408201
406
359
ui = tests.TestUIFactory()
407
360
pb = ui.nested_progress_bar()
408
361
pb.update('hello')