~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Jelmer Vernooij
  • Date: 2012-06-18 11:43:07 UTC
  • mfrom: (6437.54.10 2.5)
  • mto: This revision was merged to the branch mainline in revision 6525.
  • Revision ID: jelmer@samba.org-20120618114307-zeazlym311p38m98
MergeĀ 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    )
32
32
from bzrlib.tests import (
33
33
    fixtures,
34
 
    test_progress,
35
34
    )
36
35
from bzrlib.ui import text as _mod_ui_text
37
36
from bzrlib.tests.testui import (
39
38
    )
40
39
 
41
40
 
 
41
class TTYStringIO(StringIO):
 
42
    """A helper class which makes a StringIO look like a terminal"""
 
43
 
 
44
    def isatty(self):
 
45
        return True
 
46
 
 
47
 
 
48
class NonTTYStringIO(StringIO):
 
49
    """Helper that implements isatty() but returns False"""
 
50
 
 
51
    def isatty(self):
 
52
        return False
 
53
 
 
54
 
42
55
class TestUIConfiguration(tests.TestCaseWithTransport):
43
56
 
44
57
    def test_output_encoding_configuration(self):
221
234
 
222
235
    def test_text_factory_prompts_and_clears(self):
223
236
        # a get_boolean call should clear the pb before prompting
224
 
        out = test_progress._TTYStringIO()
 
237
        out = TTYStringIO()
225
238
        self.overrideEnv('TERM', 'xterm')
226
239
        factory = _mod_ui_text.TextUIFactory(
227
240
            stdin=tests.StringIOWrapper("yada\ny\n"),
292
305
    def test_quietness(self):
293
306
        self.overrideEnv('BZR_PROGRESS_BAR', 'text')
294
307
        ui_factory = _mod_ui_text.TextUIFactory(None,
295
 
            test_progress._TTYStringIO(),
296
 
            test_progress._TTYStringIO())
 
308
            TTYStringIO(),
 
309
            TTYStringIO())
297
310
        self.assertIsInstance(ui_factory._progress_view,
298
311
            _mod_ui_text.TextProgressView)
299
312
        ui_factory.be_quiet(True)
358
371
    def test_progress_construction(self):
359
372
        """TextUIFactory constructs the right progress view.
360
373
        """
361
 
        TTYStringIO = test_progress._TTYStringIO
362
374
        FileStringIO = tests.StringIOWrapper
363
375
        for (file_class, term, pb, expected_pb_class) in (
364
376
            # on an xterm, either use them or not as the user requests,
391
403
 
392
404
    def test_text_ui_non_terminal(self):
393
405
        """Even on non-ttys, make_ui_for_terminal gives a text ui."""
394
 
        stdin = test_progress._NonTTYStringIO('')
395
 
        stderr = test_progress._NonTTYStringIO()
396
 
        stdout = test_progress._NonTTYStringIO()
 
406
        stdin = NonTTYStringIO('')
 
407
        stderr = NonTTYStringIO()
 
408
        stdout = NonTTYStringIO()
397
409
        for term_type in ['dumb', None, 'xterm']:
398
410
            self.overrideEnv('TERM', term_type)
399
411
            uif = _mod_ui.make_ui_for_terminal(stdin, stdout, stderr)