Skip to content

fix: keep multi-browser parametrization when the page fixture is overridden - #314

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
cycsmail:fix/multi-browser-overridden-page-fixture
Oct 7, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
cycsmail:fix/multi-browser-overridden-page-fixture

Conversation

@cycsmail

Copy link
Copy Markdown
Contributor

Summary

  • When a user overrides the page fixture (e.g. def page(page): yield page), some pytest versions drop browser_name from the fixture closure, so --browser chromium --browser firefox silently runs the test against only one browser instead of parametrizing it.
  • In pytest_generate_tests, if browser_name is absent but a browser-backed fixture (page, context, new_context, browser, browser_type) is requested, re-add browser_name to metafunc.fixturenames before parametrizing. It's a no-op when browser_name is already present (pytest 9) or when no browser fixture is used, so non-browser tests are untouched.
  • Applied to both the sync and asyncio plugins, with a regression test in each that collects test_a[chromium] and test_a[firefox] from an overridden page fixture.

Reverting the plugin change makes the new tests fail on pytest 8.3.5 (only test_a is collected), confirming they guard the regression. On pytest 9 the closure already keeps browser_name, so the tests pass there regardless.

Fixes #172

@cycsmail

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@pavelfeldman
Pavel Feldman (pavelfeldman) force-pushed the fix/multi-browser-overridden-page-fixture branch from 6eb5de1 to c7d6c3c Compare October 7, 2026 22:31
@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit 0356d90 into microsoft:main Oct 7, 2026
12 checks passed
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.

[BUG] Can't run tests with multiple browsers when overriding page fixture

3 participants