def observe(matcher):
@functools.wraps(matcher)<EOL>def observer(self, subject, *expected, **kw):<EOL><INDENT>if hasattr(self, '<STR_LIT>'):<EOL><INDENT>self.before(subject, *expected, **kw)<EOL><DEDENT>result = matcher(self, subject, *expected, **kw)<EOL>if result is not True and hasattr(self, '<STR_LIT>'):<EOL><INDENT>self.after_error(result, subject, *expected, **kw)<EOL><DEDENT>if result is True and hasattr(self, '<STR_LIT>'):<EOL><INDENT>self.after_success(subject, *expected, **kw)<EOL><DEDENT>if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>self.show_diff = all([<EOL>isinstance(subject, six.string_types),<EOL>all([isinstance(x, six.string_types) for x in expected]),<EOL>])<EOL><DEDENT>return result<EOL><DEDENT>return observer<EOL>
Internal decorator to trigger operator hooks before/after
matcher execution.