pytest-csv-params/tests/poc/conftest.py

52 lines
1.1 KiB
Python

"""
Local configuration and fixture providing for POC tests
"""
from typing import Dict, Type
import pytest
class CheapCounter:
"""
A simple cheap counter that is required for counting executions
"""
counter: Dict[str, int] = {}
@classmethod
def get_value(cls, counter: str) -> int:
"""
Get the value of the counter
:param counter: Name of the counter
:returns: Value of the counter
"""
current_value = cls.counter.get(counter, None)
if current_value is None:
cls.counter[counter] = 0
return 0
return current_value
@classmethod
def increment(cls, counter: str) -> None:
"""
Increment the value of the counter
:param counter: Name of the counter to increment
"""
cls.counter[counter] = cls.get_value(counter) + 1
@pytest.fixture(scope="session")
def cheap_counter() -> Type[CheapCounter]:
"""
Deliver a simple counter as fixture
:returns: The Cheap Counter Class
"""
return CheapCounter