9Log Filter class to replace string occurences in log messages to simplify testing
16 Simple class to intercept anything written to
python stdout and replace
17 a given set of strings
with placehholders to improve reproducibility.
21 """Setup the forwarding and replacements
24 out (file object): Where to forward the output too
25 replacements (dict(str, str)): Dictionary of strings and their replacements
32 self._regex = re.compile("|".join(re.escape(e)
for e
in replacements))
35 """Check all messages for strings to replace"""
40 """Forward all other methods from the out stream"""
41 return getattr(self.
_out, name)
def __getattr__(self, name)
_out
where to forward output
_replacements
what to replace
def __init__(self, out, replacements)
_regex
build a regular expression from dictionary keys