"""Test utils.""" from re import sub from typing import Callable def feature_flag_func(mapping: dict) -> Callable: """Create a feature flag side-effect function with a mapping of values. Args: mapping (dict): Feature flag to active mapping Returns: Callable: Side-effect function """ def check_flag(flag: str) -> bool: """Check whether the feature flag should be true/false. Args: flag (str): Feature flag to check Returns: bool: Whether the flag is active """ if flag in mapping: return mapping[flag] return False return check_flag def strip_whitespace(text: str) -> str: """Remove all whitespace from some text. Args: text (str): Text to remove whitespace from. Returns: str: Whitespace-less text. """ return sub(r'\s', '', text)