Files
python-learning/exercises/02-engineering-2026/04-testing-best-practices/test_testing_ex.py
T

15 lines
513 B
Python

import pytest
from testing_ex import FeatureFlagService, InMemoryKvStore
@pytest.mark.parametrize(
("raw_value", "expected"),
[("true", True), ("TRUE", True), ("1", True), ("false", False), ("0", False), (None, False)],
)
def test_feature_flag_service_with_in_memory_fake(raw_value: str | None, expected: bool) -> None:
store = InMemoryKvStore()
if raw_value is not None:
store.set("new_ui", raw_value)
svc = FeatureFlagService(store)
assert svc.is_enabled("new_ui") is expected