From c90ffd4a4f3bdca2342fee70f6074a6167549501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Mon, 10 Jun 2024 18:52:20 +0200 Subject: [PATCH] Fix test-CI (#6909) --- panel/pane/holoviews.py | 15 ++++++++++----- panel/tests/conftest.py | 8 ++++++++ panel/tests/ui/layout/test_feed.py | 2 +- panel/tests/ui/widgets/test_select.py | 2 +- pixi.toml | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/panel/pane/holoviews.py b/panel/pane/holoviews.py index 0f727619b0..b55639bf40 100644 --- a/panel/pane/holoviews.py +++ b/panel/pane/holoviews.py @@ -37,6 +37,12 @@ from pyviz_comms import Comm +def check_holoviews(version): + import holoviews as hv + + return Version(Version(hv.__version__).base_version) >= Version(version) + + class HoloViews(PaneBase): """ `HoloViews` panes render any `HoloViews` object using the @@ -487,8 +493,6 @@ def _get_pane(self, backend, state, **kwargs): return pane_type(state, **kwargs) def _render(self, doc, comm, root): - import holoviews as hv - from holoviews import Store, renderer as load_renderer if self.renderer: @@ -516,7 +520,7 @@ def _render(self, doc, comm, root): renderer = renderer.instance(**params) kwargs = {'margin': self.margin} - if backend == 'bokeh' or Version(str(hv.__version__)) >= Version('1.13.0'): + if backend == 'bokeh' or check_holoviews('1.13.0'): kwargs['doc'] = doc kwargs['root'] = root if comm: @@ -807,7 +811,8 @@ def find_links(root_view, root_model): plots = [(plot, root_plot) for root_plot in root_plots for plot in root_plot.traverse(lambda x: x, [is_bokeh_element_plot])] - potentials = [(LinkCallback.find_link(plot), root_plot) + link_kwargs = {'target': True} if check_holoviews('1.19') else {} + potentials = [(LinkCallback.find_link(plot, **link_kwargs), root_plot) for plot, root_plot in plots] source_links = [p for p in potentials if p[0] is not None] @@ -818,7 +823,7 @@ def find_links(root_view, root_model): # If link has no target don't look further found.append((link, plot, None)) continue - potentials = [LinkCallback.find_link(plot, link) for plot, inner_root in plots + potentials = [LinkCallback.find_link(plot, link, **link_kwargs) for plot, inner_root in plots if inner_root is not root_plot] tgt_links = [p for p in potentials if p is not None] if tgt_links: diff --git a/panel/tests/conftest.py b/panel/tests/conftest.py index 5d2fc4ad39..f592ac635b 100644 --- a/panel/tests/conftest.py +++ b/panel/tests/conftest.py @@ -12,6 +12,7 @@ import tempfile import time import unittest +import warnings from contextlib import contextmanager from subprocess import PIPE, Popen @@ -40,6 +41,13 @@ JUPYTER_TIMEOUT = 15 # s JUPYTER_PROCESS = None +try: + with warnings.catch_warnings(): + warnings.filterwarnings("error", category=DeprecationWarning) + asyncio.get_event_loop() +except (RuntimeError, DeprecationWarning): + asyncio.set_event_loop(asyncio.new_event_loop()) + def port_open(port): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(1) diff --git a/panel/tests/ui/layout/test_feed.py b/panel/tests/ui/layout/test_feed.py index fdf6bd7bb4..3dd68f6df5 100644 --- a/panel/tests/ui/layout/test_feed.py +++ b/panel/tests/ui/layout/test_feed.py @@ -46,7 +46,7 @@ def test_feed_view_latest(page): expect(feed_el).to_have_class("bk-panel-models-feed-Feed scroll-vertical") # Assert scroll is not at 0 (view_latest) - assert feed_el.evaluate('(el) => el.scrollTop') > 0 + wait_until(lambda: feed_el.evaluate('(el) => el.scrollTop') > 0, page) wait_until(lambda: int(page.locator('pre').last.inner_text()) > 0.9 * ITEMS, page) diff --git a/panel/tests/ui/widgets/test_select.py b/panel/tests/ui/widgets/test_select.py index cae5a8612f..8e4066e90e 100644 --- a/panel/tests/ui/widgets/test_select.py +++ b/panel/tests/ui/widgets/test_select.py @@ -30,4 +30,4 @@ def test_multi_select_double_click(page): page.locator('option').nth(1).dblclick() - wait_until(lambda: clicks and clicks[0].option == 'B') + wait_until(lambda: bool(clicks) and clicks[0].option == 'B') diff --git a/pixi.toml b/pixi.toml index 2f5257fac1..fd4129cc57 100644 --- a/pixi.toml +++ b/pixi.toml @@ -127,7 +127,7 @@ nbval = "*" channels = ["pyviz/label/dev", "bokeh", "microsoft", "conda-forge"] [feature.test-ui.dependencies] -playwright = "*" +playwright = { version = "*", channel = "microsoft" } pytest-playwright = "*" jupyter_server = "*"