def METHOD_NAME(capture_events, init_huey, lock_name):
    huey = init_huey()
    task_lock_name = "lock.a"
    should_be_locked = task_lock_name == lock_name
    @huey.task()
    @huey.lock_task(task_lock_name)
    def maybe_locked_task():
        pass
    events = capture_events()
    with huey.lock_task(lock_name):
        assert huey.is_locked(task_lock_name) == should_be_locked
        result = execute_huey_task(huey, maybe_locked_task)
    (event,) = events
    assert event["transaction"] == "maybe_locked_task"
    assert event["tags"]["huey_task_id"] == result.task.id
    assert (
        event["contexts"]["trace"]["status"] == "aborted" if should_be_locked else "ok"
    )
    assert len(huey) == 0