mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-07-01 23:19:54 +02:00
counter: add reset();
This commit is contained in:
parent
a3465ca1a0
commit
a678bbf966
2 changed files with 11 additions and 2 deletions
|
@ -7,8 +7,13 @@ class EynollahIdCounter():
|
||||||
|
|
||||||
def __init__(self, region_idx=0, line_idx=0):
|
def __init__(self, region_idx=0, line_idx=0):
|
||||||
self._counter = Counter()
|
self._counter = Counter()
|
||||||
self.set('region', region_idx)
|
self._inital_region_idx = region_idx
|
||||||
self.set('line', line_idx)
|
self._inital_line_idx = line_idx
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.set('region', self._inital_region_idx)
|
||||||
|
self.set('line', self._inital_line_idx)
|
||||||
|
|
||||||
def inc(self, name, val=1):
|
def inc(self, name, val=1):
|
||||||
self._counter.update({name: val})
|
self._counter.update({name: val})
|
||||||
|
|
|
@ -14,6 +14,10 @@ def test_counter_string():
|
||||||
def test_counter_init():
|
def test_counter_init():
|
||||||
c = EynollahIdCounter(region_idx=2)
|
c = EynollahIdCounter(region_idx=2)
|
||||||
assert c.get('region') == 2
|
assert c.get('region') == 2
|
||||||
|
c.inc('region')
|
||||||
|
assert c.get('region') == 3
|
||||||
|
c.reset()
|
||||||
|
assert c.get('region') == 2
|
||||||
|
|
||||||
def test_counter_methods():
|
def test_counter_methods():
|
||||||
c = EynollahIdCounter()
|
c = EynollahIdCounter()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue