File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
2+
3+ import pytest
4+
5+
6+ @pytest .fixture
7+ def asyncio_loop ():
8+ loop = asyncio .new_event_loop ()
9+ asyncio .set_event_loop (asyncio .new_event_loop ())
10+ yield
11+ loop .stop ()
12+ loop .close ()
Original file line number Diff line number Diff line change 1- import time
2-
31import anywidget
42import panel as pn
53import traitlets
6- from panel .io . server import serve
7- from playwright .sync_api import expect , Page
4+ from panel .tests . util import serve_and_wait
5+ from playwright .sync_api import Page , expect
86
97
108class CounterWidget (anywidget .AnyWidget ):
@@ -33,7 +31,7 @@ class CounterWidget(anywidget.AnyWidget):
3331 count = traitlets .Int (default_value = 0 ).tag (sync = True )
3432
3533
36- def test_anywidget (page : Page ) -> None :
34+ def test_anywidget (page : Page , asyncio_loop ) -> None :
3735 """Test anywidget button counter example."""
3836 # Port to run the panel server on.
3937 port = 5006
@@ -44,8 +42,7 @@ def test_anywidget(page: Page) -> None:
4442
4543 # Serve the button using panel, the time delay is necessary for panel to start and
4644 # serve the widget.
47- serve (panels = panels , port = port , show = False )
48- time .sleep (0.2 )
45+ serve_and_wait (panels , port = port )
4946
5047 # Go to the page and locate the widget using playwright.
5148 page .goto (f"http://localhost:{ port } " )
You can’t perform that action at this time.
0 commit comments