~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
158
158
    def test_text_factory_prompts_and_clears(self):
159
159
        # a get_boolean call should clear the pb before prompting
160
160
        out = test_progress._TTYStringIO()
161
 
        os.environ['TERM'] = 'xterm'
 
161
        self.overrideEnv('TERM', 'xterm')
162
162
        factory = _mod_ui_text.TextUIFactory(
163
163
            stdin=tests.StringIOWrapper("yada\ny\n"),
164
164
            stdout=out, stderr=out)
226
226
            pb.finished()
227
227
 
228
228
    def test_quietness(self):
229
 
        os.environ['BZR_PROGRESS_BAR'] = 'text'
 
229
        self.overrideEnv('BZR_PROGRESS_BAR', 'text')
230
230
        ui_factory = _mod_ui_text.TextUIFactory(None,
231
231
            test_progress._TTYStringIO(),
232
232
            test_progress._TTYStringIO())
313
313
            # however, it can still be forced on
314
314
            (FileStringIO, 'dumb', 'text', _mod_ui_text.TextProgressView),
315
315
            ):
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
 
316
            self.overrideEnv('TERM', term)
 
317
            self.overrideEnv('BZR_PROGRESS_BAR', pb)
322
318
            stdin = file_class('')
323
319
            stderr = file_class()
324
320
            stdout = file_class()
335
331
        stderr = test_progress._NonTTYStringIO()
336
332
        stdout = test_progress._NonTTYStringIO()
337
333
        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
 
334
            self.overrideEnv('TERM', term_type)
342
335
            uif = _mod_ui.make_ui_for_terminal(stdin, stdout, stderr)
343
336
            self.assertIsInstance(uif, _mod_ui_text.TextUIFactory,
344
337
                'TERM=%r' % (term_type,))