summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlain Leufroy <alain.leufroy@logilab.fr>2012-03-15 13:37:49 +0100
committerAlain Leufroy <alain.leufroy@logilab.fr>2012-03-15 13:37:49 +0100
commitcd55c7901ff556b0593c129536e258554d5165d0 (patch)
tree7acbe0bc3ec71cea864a38b9720a83aa0dee56b0 /test
parent70683711afccf2d454b81b7903112c8f09f73fcd (diff)
downloadlogilab-common-cd55c7901ff556b0593c129536e258554d5165d0.tar.gz
[shellutil] add argument to ``ProgressBar.update`` to tune cursor progression (closes #88981)
Diffstat (limited to 'test')
-rw-r--r--test/unittest_shellutils.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/unittest_shellutils.py b/test/unittest_shellutils.py
index 81c4397..fb9e1ca 100644
--- a/test/unittest_shellutils.py
+++ b/test/unittest_shellutils.py
@@ -144,6 +144,30 @@ class ProgressBarTC(TestCase):
def test_overflow(self):
self._update_test(5, (8, 16, 25, 33, 42, (42, True)), size=42)
+ def test_update_exact(self):
+ pgb_stream = StringIO()
+ expected_stream = StringIO()
+ size=20
+ pgb = ProgressBar(100, size, stream=pgb_stream)
+ last = 0
+ for dots in xrange(10, 105, 15):
+ pgb.update(dots, exact=True)
+ dots /= 5
+ expected_stream.write("\r["+('.'*dots)+(' '*(size-dots))+"]")
+ self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())
+
+ def test_update_relative(self):
+ pgb_stream = StringIO()
+ expected_stream = StringIO()
+ size=20
+ pgb = ProgressBar(100, size, stream=pgb_stream)
+ last = 0
+ for dots in xrange(5, 105, 5):
+ pgb.update(5, exact=False)
+ dots /= 5
+ expected_stream.write("\r["+('.'*dots)+(' '*(size-dots))+"]")
+ self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())
+
class AcquireLockTC(TestCase):