Skip to content

open_login test: bring its own Playwright error types so a leaked stub cannot break it - #16784

Merged
danielhanchen merged 1 commit into
mainfrom
open-login-test-own-playwright
Nov 5, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
open-login-test-own-playwright

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

#16768 added tests/studio/test_playwright_multi_account_open_login.py, and all 7 of its tests fail in Repo tests (CPU, studio) when an earlier test in the same worker has stubbed Playwright, for example the staging run for #16613:

test_a_redirect_that_already_loaded_login_is_used
E   RuntimeError: playwright is not installed: Error needs a real browser
E   TypeError: catching classes that do not inherit from BaseException is not allowed
test_a_second_failure_of_the_same_kind_is_real[two aborts]
E   TypeError: Expected a BaseException type, but got 'function'
7 failed, 10029 passed

The CPU jobs do not install Playwright. tests/studio/test_heavy_thread_measurement_integrity.py handles that by putting a stub playwright.sync_api into sys.modules that answers every name with a function that raises. My test guarded with pytest.importorskip("playwright.sync_api"), which finds that stub, so it ran with functions where it expected exception types. Run alone, or with real Playwright installed, it passed, which is why #16768's own checks were green.

Change

tests/studio/test_playwright_multi_account_open_login.py only. The test no longer imports Playwright. It defines Error and TimeoutError(Error) itself, matching Playwright's own hierarchy, and while loading the driver it puts a minimal playwright.sync_api carrying them into sys.modules through monkeypatch, which restores the previous modules after each test. The test now runs, rather than skips, on the CPU jobs, whatever earlier tests left behind. The driver and the test cases are unchanged.

Testing

With Playwright made unimportable and test_heavy_thread_measurement_integrity.py run first in the same process, as on CI:

result
main 7 failed, 76 passed (the errors above)
this branch 83 passed

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T12:53:09.439243Z a4069cb Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: a4069cb03c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 2395605 into main Nov 5, 2026
@danielhanchen
danielhanchen deleted the open-login-test-own-playwright branch November 5, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant