~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Martin
  • Date: 2011-04-15 21:22:57 UTC
  • mto: This revision was merged to the branch mainline in revision 5797.
  • Revision ID: gzlist@googlemail.com-20110415212257-jgtovwwp4be7egd9
Add release notes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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
17
17
"""Tests for the bzrlib ui
18
18
"""
19
19
 
20
 
import os
21
20
import time
22
21
 
23
22
from StringIO import StringIO
26
25
 
27
26
from bzrlib import (
28
27
    config,
29
 
    errors,
30
28
    remote,
31
 
    repository,
32
29
    tests,
33
30
    ui as _mod_ui,
34
31
    )
35
 
from bzrlib.symbol_versioning import (
36
 
    deprecated_in,
37
 
    )
38
32
from bzrlib.tests import (
39
33
    fixtures,
40
34
    test_progress,
158
152
    def test_text_factory_prompts_and_clears(self):
159
153
        # a get_boolean call should clear the pb before prompting
160
154
        out = test_progress._TTYStringIO()
161
 
        os.environ['TERM'] = 'xterm'
 
155
        self.overrideEnv('TERM', 'xterm')
162
156
        factory = _mod_ui_text.TextUIFactory(
163
157
            stdin=tests.StringIOWrapper("yada\ny\n"),
164
158
            stdout=out, stderr=out)
226
220
            pb.finished()
227
221
 
228
222
    def test_quietness(self):
229
 
        os.environ['BZR_PROGRESS_BAR'] = 'text'
 
223
        self.overrideEnv('BZR_PROGRESS_BAR', 'text')
230
224
        ui_factory = _mod_ui_text.TextUIFactory(None,
231
225
            test_progress._TTYStringIO(),
232
226
            test_progress._TTYStringIO())
238
232
 
239
233
    def test_text_ui_show_user_warning(self):
240
234
        from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
241
 
        from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack5
 
235
        from bzrlib.repofmt.knitpack_repo import RepositoryFormatKnitPack5
242
236
        err = StringIO()
243
237
        out = StringIO()
244
238
        ui = tests.TextUIFactory(stdin=None, stdout=out, stderr=err)
313
307
            # however, it can still be forced on
314
308
            (FileStringIO, 'dumb', 'text', _mod_ui_text.TextProgressView),
315
309
            ):
316
 
            os.environ['TERM'] = term
317
 
            if pb is None:
318
 
                if 'BZR_PROGRESS_BAR' in os.environ:
319
 
                    del os.environ['BZR_PROGRESS_BAR']
320
 
            else:
321
 
                os.environ['BZR_PROGRESS_BAR'] = pb
 
310
            self.overrideEnv('TERM', term)
 
311
            self.overrideEnv('BZR_PROGRESS_BAR', pb)
322
312
            stdin = file_class('')
323
313
            stderr = file_class()
324
314
            stdout = file_class()
335
325
        stderr = test_progress._NonTTYStringIO()
336
326
        stdout = test_progress._NonTTYStringIO()
337
327
        for term_type in ['dumb', None, 'xterm']:
338
 
            if term_type is None:
339
 
                del os.environ['TERM']
340
 
            else:
341
 
                os.environ['TERM'] = term_type
 
328
            self.overrideEnv('TERM', term_type)
342
329
            uif = _mod_ui.make_ui_for_terminal(stdin, stdout, stderr)
343
330
            self.assertIsInstance(uif, _mod_ui_text.TextUIFactory,
344
331
                'TERM=%r' % (term_type,))