<commit_before>from __future__ import absolute_import

from bokeh.io import save
from bokeh.models import HoverTool
from bokeh.plotting import figure
from selenium.webdriver.common.action_chains import ActionChains

import pytest
pytestmark = pytest.mark.integration

HEIGHT = 600
WIDTH = 600


def hover_at_position(selenium, canvas, x, y):
    actions = ActionChains(selenium)
    actions.move_to_element_with_offset(canvas, x, y)
    actions.perform()


def test_hover_changes_color(output_file_url, selenium, screenshot):

    # Make plot and add a taptool callback that generates an alert
    plot = figure(height=HEIGHT, width=WIDTH, tools='')
    rect = plot.rect(
        x=[1, 2], y=[1, 1],
        width=1, height=1,
        fill_color='cyan', hover_fill_color='magenta',
        line_color=None,   hover_line_color=None
    )
    plot.add_tools(HoverTool(tooltips=None, renderers=[rect]))

    # Save the plot and start the test
    save(plot)
    selenium.get(output_file_url)

    # Hover over plot and take screenshot
    canvas = selenium.find_element_by_tag_name('canvas')
    hover_at_position(selenium, canvas, WIDTH * 0.33, HEIGHT * 0.5)
    assert screenshot.is_valid()<commit_msg>Deliberately fail the hover test<commit_after>from __future__ import absolute_import

from bokeh.io import save
from bokeh.models import HoverTool
from bokeh.plotting import figure
from selenium.webdriver.common.action_chains import ActionChains

import pytest
pytestmark = pytest.mark.integration

HEIGHT = 600
WIDTH = 600


def hover_at_position(selenium, canvas, x, y):
    actions = ActionChains(selenium)
    actions.move_to_element_with_offset(canvas, x, y)
    actions.perform()


def test_hover_changes_color(output_file_url, selenium, screenshot):

    # Make plot and add a taptool callback that generates an alert
    plot = figure(height=HEIGHT, width=WIDTH, tools='')
    rect = plot.rect(
        x=[1, 2], y=[1, 1],
        width=1, height=1,
        fill_color='blue', hover_fill_color='magenta',
        line_color=None,   hover_line_color=None
    )
    plot.add_tools(HoverTool(tooltips=None, renderers=[rect]))

    # Save the plot and start the test
    save(plot)
    selenium.get(output_file_url)

    # Hover over plot and take screenshot
    canvas = selenium.find_element_by_tag_name('canvas')
    hover_at_position(selenium, canvas, WIDTH * 0.33, HEIGHT * 0.5)
    assert screenshot.is_valid()
{'fraction_non_alphanumeric': 0.09169764560099132, 'fraction_numerical': 0.014043783560512184, 'mean_word_length': 4.208602150537635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5516181', 'n_tokens_mistral': 836, 'n_tokens_neox': 781, 'n_words': 197}