Skip to content

[BUG] 浏览器测试在本地静默消失:12 个交互用例塌缩成 1 条 skip #278

Closed

Description

@codeasier

Bug 描述

tests/test_memory_tree_browser.py 在模块顶层调用 pytest.importorskip("playwright.sync_api")。playwright 包不可导入时,整个模块在收集阶段被跳过:collected 0 items / 1 skipped,12 个用例一条都不进执行计划,也不会出现在 passed 计数里。

即使 playwright 包已安装、但 Chromium 二进制未安装(普通 .[dev] 安装正是这种状态),chromium_browser fixture 也只是 pytest.skip(...),12 条用例变成 12 条跳过,作业照常变绿。只有 .github/workflows/test.yml 的 browser 作业设置 PT_SNAP_REQUIRE_BROWSER=1 并执行 playwright install,才把“没装浏览器”升级为失败。

复现步骤

  1. 在未安装 playwright 的环境执行 python -m pytest tests/test_memory_tree_browser.py -q -rs
  2. 观察 collected 0 items / 1 skipped
  3. 在已装 playwright 包、未跑 python -m playwright install chromium 的环境重复第 1 步
  4. 观察 12 条 skip 且退出码为 0

预期行为

浏览器回归是否真正执行对使用者可见;“未执行”不应与“执行且通过”在 CI 上同义。

实际行为

本机(未安装 playwright)模块级跳过,collected 0 / 1 skipped;全量 pytest -m "not slow and not nightly" 只报告 3 skipped,浏览器层没有任何计数。

.github/workflows/test.yml 的 test 矩阵与 .github/workflows/platform.yml 都只执行 pip install -e ".[dev]"(playwright 在 dev extra 内),既不安装 Chromium,也不设置 PT_SNAP_REQUIRE_BROWSER。

操作系统

macOS

Python 版本

3.13.11

pt-snap-cli 版本

0.4.0(HEAD f876665,v0.4.1-4-gf876665)

日志/错误信息

$ python -m pytest tests/test_memory_tree_browser.py -q -rs
collected 0 items / 1 skipped
SKIPPED [1] tests/test_memory_tree_browser.py:22: could not import 'playwright.sync_api': No module named 'playwright'

补充信息

12 个用例全部依赖 browser_page fixture;fixture 内的跳过判定依赖 "executable doesn't exist" in str(exc).lower() 这一字符串匹配,所以“包在、浏览器不在”的环境同样是绿色。

Activity

  1. codeasier commented on Nov 1, 2026

    @codeasier
    OwnerAuthor

    Implemented by PR #283: all 12 browser regressions remain collected; optional environments explicitly report not-executed counts, while the required-browser lane fails closed on missing support, skips, empty/deselected or incomplete execution. Positive and negative regressions are retained.

    Merged main: 39f3762e9e54344433dc44e23da69e03c1c64984. Independent review and pre-merge checks passed. Post-merge Test and Platform compatibility are completed successfully, including required Chromium and all macOS/Windows jobs. The event-inapplicable nightly dataset lane is skipped, not claimed as a pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions