Source code for noob.testing.assets

from collections.abc import Generator
from typing import Any

from noob.asset import Asset


[docs] class counter(Generator): """ custom generator because itertools is removing deepcopy in 3.14 https://docs.python.org/3/deprecations/pending-removal-in-3.14.html """ def __init__(self, start: int = 0) -> None: self.start = start self._current = start
[docs] def send(self, _: Any) -> int: current = self._current self._current += 1 return current
[docs] def throw(self, type: Any = None, value: Any = None, traceback: Any = None) -> None: raise StopIteration()
@property def current(self) -> int: return self._current
[docs] class Initializer(Asset): """True when initialized, false when deinitialized""" obj: bool = False
[docs] def init(self) -> None: self.obj = True
[docs] def deinit(self) -> None: self.obj = False