@contextmanager
def access_given_class(TowerClass):
    try:
        mock_instance = mock.MagicMock(__name__='foobar')
        MockAccess = mock.MagicMock(return_value=mock_instance)
        the_patch = mock.patch.dict('awx.main.access.access_registry', {TowerClass: MockAccess}, clear=False)
        the_patch.__enter__()
        (yield mock_instance)
    finally:
        the_patch.__exit__()
@contextmanager
def access_given_class(TowerClass):
    try:
        mock_instance = mock.MagicMock(__name__='foobar')
        MockAccess = mock.MagicMock(return_value=mock_instance)
        the_patch = mock.patch.dict('awx.main.access.access_registry', {TowerClass: MockAccess}, clear=False)
        the_patch.__enter__()
        (yield mock_instance)
    finally:
        the_patch.__exit__()