Beispiel #1
0
 def size_hint(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=20)
     widget = PercentageWidget()
     assert widget.provides_size_hint
     Assert(widget.size_hint(progressbar)) == 2
     progressbar.step = 1
     Assert(widget.size_hint(progressbar)) == 2
     progressbar.step = 2
     Assert(widget.size_hint(progressbar)) == 3
     progressbar.step = 20
     Assert(widget.size_hint(progressbar)) == 4
Beispiel #2
0
 def size_hint(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=20)
     widget = PercentageWidget()
     assert widget.provides_size_hint
     Assert(widget.size_hint(progressbar)) == 2
     progressbar.step = 1
     Assert(widget.size_hint(progressbar)) == 2
     progressbar.step = 2
     Assert(widget.size_hint(progressbar)) == 3
     progressbar.step = 20
     Assert(widget.size_hint(progressbar)) == 4
Beispiel #3
0
    def step(self):
        writer = TerminalWriter(StringIO())
        progressbar = ProgressBar([], writer)
        Assert(progressbar.step) == 0
        progressbar.step = 100
        Assert(progressbar.step) == 100

        progressbar = ProgressBar([], writer, maxsteps=100)
        Assert(progressbar.step) == 0
        progressbar.step = 100
        Assert(progressbar.step) == 100
        with Assert.raises(ValueError):
            progressbar.step = 200
Beispiel #4
0
    def step(self):
        writer = TerminalWriter(StringIO())
        progressbar = ProgressBar([], writer)
        Assert(progressbar.step) == 0
        progressbar.step = 100
        Assert(progressbar.step) == 100

        progressbar = ProgressBar([], writer, maxsteps=100)
        Assert(progressbar.step) == 0
        progressbar.step = 100
        Assert(progressbar.step) == 100
        with Assert.raises(ValueError):
            progressbar.step = 200
Beispiel #5
0
    def units(self):
        class FooStepWidget(StepWidget):
            units = {'foo': lambda x: str(x) + 'spam'}

        writer = TerminalWriter(StringIO())
        progressbar = ProgressBar([], writer, maxsteps=20)
        widget = FooStepWidget('foo')
        Assert(widget.init(progressbar, 100)) == '0spam of 20spam'
        progressbar.step += 1
        Assert(widget.init(progressbar, 100)) == '1spam of 20spam'
        progressbar.step = progressbar.maxsteps
        Assert(widget.finish(progressbar, 100)) == '20spam of 20spam'
Beispiel #6
0
    def units(self):
        class FooStepWidget(StepWidget):
            units = {'foo': lambda x: str(x) + 'spam'}

        writer = TerminalWriter(StringIO())
        progressbar = ProgressBar([], writer, maxsteps=20)
        widget = FooStepWidget('foo')
        Assert(widget.init(progressbar, 100)) == '0spam of 20spam'
        progressbar.step +=1
        Assert(widget.init(progressbar, 100)) == '1spam of 20spam'
        progressbar.step = progressbar.maxsteps
        Assert(widget.finish(progressbar, 100)) == '20spam of 20spam'
Beispiel #7
0
 def finish(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=20)
     widget = StepWidget()
     progressbar.step = progressbar.maxsteps
     Assert(widget.finish(progressbar, writer.get_width())) == '20 of 20'
Beispiel #8
0
 def finish(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=20)
     widget = StepWidget()
     progressbar.step = progressbar.maxsteps
     Assert(widget.finish(progressbar, writer.get_width())) == '20 of 20'