Coverage for src / ocarina / opinionated / infra / act_counter.py: 56.25%
14 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-06-04 16:22 +0200
« prev ^ index » next coverage.py v7.13.5, created at 2026-06-04 16:22 +0200
1"""ActCounter implementation proposal for TestSuites."""
3from threading import local
4from typing import Final
6from ocarina.infra.act_counter import ActCounter as _ActCounter
8_thread_local = local()
9_COUNTER_KEY: Final[str] = "ocarina_counter"
12class ActCounter(_ActCounter):
13 """Tracks act() call count across a test execution."""
15 def get(self) -> int:
16 """Return current count."""
17 return getattr(_thread_local, _COUNTER_KEY, 0)
19 def reset(self) -> None:
20 """Reset counter to zero."""
21 setattr(_thread_local, _COUNTER_KEY, 0)
23 def incr_act_call_count(self) -> None:
24 """Increment counter."""
25 if not hasattr(_thread_local, _COUNTER_KEY):
26 self.reset()
27 setattr(_thread_local, _COUNTER_KEY, getattr(_thread_local, _COUNTER_KEY) + 1)