Skip to content

Commit

Permalink
Fix flaky pop up ui tests (#6199)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Apr 19, 2024
1 parent 4727470 commit 8507aab
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions holoviews/tests/ui/bokeh/test_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

pytestmark = pytest.mark.ui

skip_popup = pytest.mark.skipif(not bokeh34, reason="Pop ups needs Bokeh 3.4")

@pytest.fixture
def points():
rng = np.random.default_rng(10)
return hv.Points(rng.normal(size=(1000, 2)))

@pytest.mark.usefixtures("bokeh_backend")
@pytest.mark.parametrize(
Expand Down Expand Up @@ -192,7 +198,8 @@ def range_function(x_range, y_range):

assert BOUND_COUNT[0] == 1

@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")

@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup(serve_hv):
def popup_form(name):
Expand All @@ -210,13 +217,12 @@ def popup_form(name):
expect(locator).to_have_count(1)


@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")
@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_none(serve_hv):
def test_stream_popup_none(serve_hv, points):
def popup_form(name):
return

points = hv.Points(np.random.randn(10, 2))
hv.streams.Tap(source=points, popup=popup_form("Tap"))

page = serve_hv(points)
Expand All @@ -235,7 +241,7 @@ def popup_form(name):
expect(locator).to_have_count(0)


@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")
@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_callbacks(serve_hv):
def popup_form(x, y):
Expand All @@ -253,9 +259,9 @@ def popup_form(x, y):
expect(locator).to_have_count(2)


@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")
@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_visible(serve_hv):
def test_stream_popup_visible(serve_hv, points):
def popup_form(x, y):
def hide(_):
col.visible = False
Expand All @@ -267,7 +273,7 @@ def hide(_):
col = pn.Column(button)
return col

points = hv.Points(np.random.randn(10, 2)).opts(tools=["tap"])
points = points.opts(tools=["tap"])
hv.streams.Tap(source=points, popup=popup_form)

page = serve_hv(points)
Expand All @@ -287,13 +293,13 @@ def hide(_):



@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")
@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_close_button(serve_hv):
def test_stream_popup_close_button(serve_hv, points):
def popup_form(x, y):
return "Hello"

points = hv.Points(np.random.randn(10, 2)).opts(tools=["tap", "box_select"])
points = points.opts(tools=["tap", "box_select"])
hv.streams.Tap(source=points, popup=popup_form)
hv.streams.BoundsXY(source=points, popup=popup_form)

Expand All @@ -309,10 +315,9 @@ def popup_form(x, y):
expect(locator).not_to_be_visible()


@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")
@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_selection1d_undefined(serve_hv):
points = hv.Points(np.random.randn(10, 2))
def test_stream_popup_selection1d_undefined(serve_hv, points):
hv.streams.Selection1D(source=points)

page = serve_hv(points)
Expand All @@ -321,13 +326,13 @@ def test_stream_popup_selection1d_undefined(serve_hv):
hv_plot.click() # should not raise any error; properly guarded


@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")
@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_selection1d(serve_hv):
def test_stream_popup_selection1d_tap(serve_hv, points):
def popup_form(index):
return "# Tap"

points = hv.Points(np.random.randn(1000, 2))
points = points.opts(hit_dilation=5)
hv.streams.Selection1D(source=points, popup=popup_form)
points.opts(tools=["tap"], active_tools=["tap"])

Expand All @@ -340,14 +345,13 @@ def popup_form(index):
expect(locator).to_have_count(1)


@pytest.mark.skipif(not bokeh34, reason="< Bokeh 3.4 does not support popup")
@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_selection1d_lasso_select(serve_hv):
def test_stream_popup_selection1d_lasso_select(serve_hv, points):
def popup_form(index):
if index:
return f"# lasso\n{len(index)}"

points = hv.Points(np.random.randn(1000, 2))
hv.streams.Selection1D(source=points, popup=popup_form)
points.opts(tools=["tap", "lasso_select"], active_tools=["lasso_select"])

Expand Down

0 comments on commit 8507aab

Please sign in to comment.