Пример #1
0
 def update(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=20)
     widget = PercentageWidget()
     widget.init(progressbar, writer.get_width())
     for i in xrange(5, 96, 5):
         progressbar.step += 1
         result = widget.update(progressbar, writer.get_width())
         Assert(result) == '%i%%' % i
Пример #2
0
 def update(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=20)
     widget = PercentageWidget()
     widget.init(progressbar, writer.get_width())
     for i in xrange(5, 96, 5):
         progressbar.step += 1
         result = widget.update(progressbar, writer.get_width())
         Assert(result) == '%i%%' % i
Пример #3
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
Пример #4
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
Пример #5
0
 def repr(self):
     widget = PercentageWidget()
     Assert(repr(widget)) == 'PercentageWidget()'
Пример #6
0
 def finish(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=100)
     widget = PercentageWidget()
     widget.init(progressbar, writer.get_width())
     Assert(widget.finish(progressbar, writer.get_width())) == '100%'
Пример #7
0
 def finish(self):
     writer = TerminalWriter(StringIO())
     progressbar = ProgressBar([], writer, maxsteps=100)
     widget = PercentageWidget()
     widget.init(progressbar, writer.get_width())
     Assert(widget.finish(progressbar, writer.get_width())) == '100%'