~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_progress.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-12-20 16:16:34 UTC
  • mfrom: (3123.5.18 hardlinks)
  • Revision ID: pqm@pqm.ubuntu.com-20071220161634-2kcjb650o21ydko4
Accelerate build_tree using similar workingtrees (abentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
        TTYProgressBar,
25
25
        DotsProgressBar,
26
26
        ProgressBarStack,
27
 
        InstrumentedProgress,
28
27
        )
29
28
from bzrlib.tests import TestCase
30
29
 
31
30
 
32
31
class FakeStack:
33
 
 
34
32
    def __init__(self, top):
35
33
        self.__top = top
36
34
 
37
35
    def top(self):
38
36
        return self.__top
39
37
 
 
38
class InstrumentedProgress(TTYProgressBar):
 
39
    """TTYProgress variant that tracks outcomes"""
 
40
 
 
41
    def __init__(self, *args, **kwargs):
 
42
        self.always_throttled = True
 
43
        TTYProgressBar.__init__(self, *args, **kwargs)
 
44
 
 
45
    def throttle(self, old_message):
 
46
        result = TTYProgressBar.throttle(self, old_message)
 
47
        if result is False:
 
48
            self.always_throttled = False
 
49
        
40
50
 
41
51
class _TTYStringIO(StringIO):
42
52
    """A helper class which makes a StringIO look like a terminal"""
53
63
 
54
64
 
55
65
class TestProgress(TestCase):
56
 
 
57
66
    def setUp(self):
58
67
        q = DummyProgress()
59
68
        self.top = ChildProgress(_stack=FakeStack(q))