Setup properties indicating status of name mock.

    This is designed to decorate ``torment.TestContext`` methods and is used to
    provide a consistent interface for determining if name is mocked once and
    only once.

    Parameters
    ----------

    :``name``: symbol in context's module to mock

    Return Value(s)
    ---------------

    True if name is mocked; otherwise, False.  Also, creates a property on the
    method's self, is_mocked_name, with this value.

def mock(name: str) -> Callable[[Any], None]:
    '''Setup properties indicating status of name mock.

    This is designed to decorate ``torment.TestContext`` methods and is used to
    provide a consistent interface for determining if name is mocked once and
    only once.

    Parameters
    ----------

    :``name``: symbol in context's module to mock

    Return Value(s)
    ---------------

    True if name is mocked; otherwise, False.  Also, creates a property on the
    method's self, is_mocked_name, with this value.

    '''

    def _(func):
        @functools.wraps(func)
        def wrapper(self, *args, **kwargs):
            logger.info('STARTING: mock ' + name)

            is_mocked = False

            sanitized_name = name.replace('.', '_').strip('_')

            if name in self.mocks_mask:
                logger.info('STOPPING: mock ' + name + '—MASKED')
            elif getattr(self, '_is_mocked_' + sanitized_name, False):
                is_mocked = True

                logger.info('STOPPING: mock ' + name + '—EXISTS')
            else:
                func(self, *args, **kwargs)

                is_mocked = True

                logger.info('STOPPING: mock ' + name)

            setattr(self, '_is_mocked_' + sanitized_name, is_mocked)

            return is_mocked

        return wrapper

    return _