跳转到主要内容

未提供项目描述

项目描述

使用playwright和pytest测试ipywidgets。

安装

pip install "pytest-ipywidgets[all]"

(注意,可选的[all]会安装所有依赖项,包括notebook、jupyterlab和voila的兼容版本。)

用法

使用solara-server(进程内)

如果您想使用playwright在进程内测试ipywidgets,您可以使用solara_test fixture,使用display在浏览器中显示您的小部件。

import ipywidgets as widgets
import playwright.sync_api
from IPython.display import display

def test_widget_button_solara(solara_test, page_session: playwright.sync_api.Page):
    # this all runs in-process
    button = widgets.Button(description="Click Me!")

    def change_description(obj):
        button.description = "Tested event"

    button.on_click(change_description)
    display(button)
    button_sel = page_session.locator("text=Click Me!")
    button_sel.wait_for()
    button_sel.click()
    page_session.locator("text=Tested event").wait_for()

在主要Jupyter环境中进行测试(Notebook、Lab、Voila & Solara)

有关更多信息,请参阅https://solara.dev/documentation/advanced/howto/testing

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

pytest_ipywidgets-1.39.0.tar.gz (2.9 kB 查看哈希值)

上传时间:

构建分发

pytest_ipywidgets-1.39.0-py2.py3-none-any.whl (4.3 kB 查看哈希值)

上传时间: Python 2 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面