fatf.utils.testing.warnings.handle_warnings_filter_pattern¶
-
fatf.utils.testing.warnings.handle_warnings_filter_pattern(warning_filter_pattern: Union[None, str, Pattern[AnyStr]], ignore_case: bool = False) → Pattern[AnyStr][source]¶ Converts a patter within a warning filter into a regex pattern.
If the input pattern is
Nonean empty (string) regex pattern is returned. A string pattern is complied directly into a regex pattern. If the input pattern is already a regex pattern it is returned without any modifications.- Parameters
- warning_filter_patternUnion[None, str, Pattern]
A pattern (
None, string or a regex pattern) extracted from a warning filter.- ignore_caseboolean, optional (default=False)
Should
re.IGNORECASEflag be compiled into the module pattern? Defaults toFalse.
- Returns
- filter_module_regexPattern
A regular expression pattern corresponding to the input warning filter module pattern.
- Raises
- TypeError
The
warning_filter_patterninput variable is neither of the following types: string, Pattern (re.compile) or None.- ValueError
The
warning_filter_patterninput variable is a Pattern but its status ofre.IGNORECASEflag does not agree with the requirement specified by theignore_caseinput variable.