~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_progress.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-10 23:00:44 UTC
  • mto: This revision was merged to the branch mainline in revision 1854.
  • Revision ID: john@arbash-meinel.com-20060710230044-8bbfddd920940ffe
new env var 'BZR_PROGRESS_BAR' to select the exact progress type

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
from StringIO import StringIO
19
19
 
 
20
from bzrlib import errors
20
21
from bzrlib.progress import (
21
22
        DummyProgress, ChildProgress,
22
23
        TTYProgressBar,
25
26
        )
26
27
from bzrlib.tests import TestCase
27
28
 
 
29
 
28
30
class FakeStack:
29
31
    def __init__(self, top):
30
32
        self.__top = top
275
277
        pb = self.get_nested(out, 'dumb')
276
278
        pb.finished()
277
279
        self.assertIsInstance(pb, DotsProgressBar)
 
280
 
 
281
    def test_progress_env_tty(self):
 
282
        # The environ variable BZR_PROGRESS_BAR controls what type of
 
283
        # progress bar we will get, even if it wouldn't usually be that type
 
284
        import cStringIO
 
285
 
 
286
        # Usually, this would be a DotsProgressBar
 
287
        out = cStringIO.StringIO()
 
288
        pb = self.get_nested(out, 'dumb', 'tty')
 
289
        pb.finished()
 
290
        # Even though we are not a tty, the env_var will override
 
291
        self.assertIsInstance(pb, TTYProgressBar)
 
292
 
 
293
    def test_progress_env_dots(self):
 
294
        # Even though we are in a tty, the env_var will override
 
295
        out = _TTYStringIO()
 
296
        pb = self.get_nested(out, 'xterm', 'dots')
 
297
        pb.finished()
 
298
        self.assertIsInstance(pb, DotsProgressBar)
 
299
 
 
300
    def test_progress_env_none(self):
 
301
        # Even though we are in a valid tty, no progress
 
302
        out = _TTYStringIO()
 
303
        pb = self.get_nested(out, 'xterm', 'none')
 
304
        pb.finished()
 
305
        self.assertIsInstance(pb, DummyProgress)
 
306
 
 
307
    def test_progress_env_invalid(self):
 
308
        out = _TTYStringIO()
 
309
        self.assertRaises(errors.InvalidProgressBarType, self.get_nested,
 
310
            out, 'xterm', 'nonexistant')