Skip to content

Commit 3fa2c2d

Browse files
committed
added method for easy incrementing
1 parent 9e7d716 commit 3fa2c2d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

progressbar/bar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,10 @@ def __enter__(self):
576576

577577
def __iadd__(self, value):
578578
'Updates the ProgressBar by adding a new value.'
579-
self.update(self.value + value)
579+
return self.increment(value)
580+
581+
def increment(self, value, *args, **kwargs):
582+
self.update(self.value + value, *args, **kwargs)
580583
return self
581584

582585
def _format_widgets(self):

tests/test_iterators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def test_adding_value():
5151
p = progressbar.ProgressBar(max_value=10)
5252
p.start()
5353
p.update(5)
54-
p += 5
54+
p += 2
55+
p.increment(2)
5556
with pytest.raises(ValueError):
5657
p += 5
5758

0 commit comments

Comments
 (0)