@contextmanager<EOL>def _patch_unwrap_mock_aware():
real_unwrap = getattr(inspect, "<STR_LIT>", None)<EOL>if real_unwrap is None:<EOL><INDENT>yield<EOL><DEDENT>else:<EOL><INDENT>def _mock_aware_unwrap(obj, stop=None):<EOL><INDENT>if stop is None:<EOL><INDENT>return real_unwrap(obj, stop=_is_mocked)<EOL><DEDENT>else:<EOL><INDENT>return real_unwrap(obj, stop=lambda obj: _is_mocked(obj) or stop(obj))<EOL><DEDENT><DEDENT>inspect.unwrap = _mock_aware_unwrap<EOL>try:<EOL><INDENT>yield<EOL><DEDENT>finally:<EOL><INDENT>inspect.unwrap = real_unwrap<EOL><DEDENT><DEDENT>
contextmanager which replaces ``inspect.unwrap`` with a version
that's aware of mock objects and doesn't recurse on them