~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Vincent Ladeuil
  • Date: 2010-10-08 10:50:51 UTC
  • mfrom: (5050.17.31 2.2.2-dev)
  • mto: This revision was merged to the branch mainline in revision 5474.
  • Revision ID: v.ladeuil+lp@free.fr-20101008105051-xd4knkrohzclffic
Merge 2.2 into trunk including fixes for bug #651706 and bug #646133

Show diffs side-by-side

added added

removed removed

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