def METHOD_NAME(codeeditor, qtbot):
    """Test decorations."""
    editor = codeeditor
    # Set random size
    editor.resize(640, random.randint(200, 500))
    # Set cell of different length.
    base_function = (
        "def some_function():\n"
        "    some_variable = 1\n"
        "    some_variable += 2\n"
        "    return some_variable\n\n"
    )
    text = ''
    for __ in range(100):
        base_text = base_function * random.randint(2, 8) + "# %%\n"
        text = text + base_text
    editor.set_text(text)
    # Move cursor over 'some_variable'
    editor.go_to_line(2)
    cursor = editor.textCursor()
    cursor.movePosition(QTextCursor.Right, n=5)
    editor.setTextCursor(cursor)
    # Assert number of decorations is the one we expect.
    qtbot.wait(3000)
    decorations = editor.decorations._sorted_decorations()
    assert len(decorations) == 2 + text.count('some_variable')
    # Assert that selection 0 is current cell
    assert decorations[0].kind == 'current_cell'
    # Assert that selection 1 is current_line
    assert decorations[1].kind == 'current_line'
    # Assert the other decorations are occurrences
    assert all([d.kind == 'occurrences' for d in decorations[2:5]])
    # Assert all other decorations are some_variable
    selected_texts = [d.cursor.selectedText() for d in decorations]
    assert set(selected_texts[2:]) == set(['some_variable'])
    # Assert painted extra selections are much smaller.
    first, last = editor.get_buffer_block_numbers()
    max_decorations = last - first
    assert len(editor.extraSelections()) < max_decorations
    # Clear decorations to be sure they are painted again below.
    editor.decorations.clear()
    editor.decorations._update()
    assert editor.decorations._sorted_decorations() == []
    # Move to a random place in the file and wait until decorations are
    # updated.
    line_number = random.randint(100, editor.blockCount())
    editor.go_to_line(line_number)
    qtbot.wait(editor.UPDATE_DECORATIONS_TIMEOUT + 100)
    # Assert a new cell is painted
    decorations = editor.decorations._sorted_decorations()
    assert decorations[0].kind == 'current_cell'