50
51
ui = tests.TestUIFactory(stdin=None,
51
52
stdout=tests.StringIOWrapper(),
52
53
stderr=tests.StringIOWrapper())
53
os = ui.make_output_stream()
54
self.assertEquals(os.encoding, enc)
54
output = ui.make_output_stream()
55
self.assertEquals(output.encoding, enc)
57
58
class TestTextUIFactory(tests.TestCase):
442
443
self.assertIsNone('0', av)
443
444
self.assertIsNone('on', av)
444
445
self.assertIsNone('off', av)
448
class TestConfirmationUserInterfacePolicy(tests.TestCase):
450
def test_confirm_action_default(self):
451
base_ui = _mod_ui.NoninteractiveUIFactory()
452
for answer in [True, False]:
454
_mod_ui.ConfirmationUserInterfacePolicy(base_ui, answer, {})
455
.confirm_action("Do something?",
456
"bzrlib.tests.do_something", {}),
459
def test_confirm_action_specific(self):
460
base_ui = _mod_ui.NoninteractiveUIFactory()
461
for default_answer in [True, False]:
462
for specific_answer in [True, False]:
463
for conf_id in ['given_id', 'other_id']:
464
wrapper = _mod_ui.ConfirmationUserInterfacePolicy(
465
base_ui, default_answer, dict(given_id=specific_answer))
466
result = wrapper.confirm_action("Do something?", conf_id, {})
467
if conf_id == 'given_id':
468
self.assertEquals(result, specific_answer)
470
self.assertEquals(result, default_answer)
473
base_ui = _mod_ui.NoninteractiveUIFactory()
474
wrapper = _mod_ui.ConfirmationUserInterfacePolicy(
475
base_ui, True, dict(a=2))
476
self.assertThat(repr(wrapper),
477
Equals("ConfirmationUserInterfacePolicy("
478
"NoninteractiveUIFactory(), True, {'a': 2})"))