from unittest.mock import patch


def class_mock(q_class_name, request):
    """
    Return a mock patching the class with qualified name *q_class_name*.
    Patch is reversed after calling test returns.
    """
    _patch = patch(q_class_name, autospec=True)
    request.addfinalizer(_patch.stop)
    return _patch.start()