From d5f3920d9dcafb0384c61a5160987479d9b7c842 Mon Sep 17 00:00:00 2001 From: MosZhao <6337796+MosZhao@users.noreply.github.com> Date: Wed, 10 Sep 2025 08:00:17 +0000 Subject: [PATCH] feat: allow browser_name as parametrize --- .../pytest_playwright_asyncio/pytest_playwright.py | 3 ++- pytest-playwright/pytest_playwright/pytest_playwright.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py b/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py index 9c165c7..d527383 100644 --- a/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py +++ b/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py @@ -92,7 +92,8 @@ def delete_output_dir(pytestconfig: Any) -> None: def pytest_generate_tests(metafunc: Any) -> None: if "browser_name" in metafunc.fixturenames: browsers = metafunc.config.option.browser or ["chromium"] - metafunc.parametrize("browser_name", browsers, scope="session") + if "browser_name" not in getattr(metafunc, "params", {}): + metafunc.parametrize("browser_name", browsers, scope="session") def pytest_configure(config: Any) -> None: diff --git a/pytest-playwright/pytest_playwright/pytest_playwright.py b/pytest-playwright/pytest_playwright/pytest_playwright.py index ec362fa..0c2919d 100644 --- a/pytest-playwright/pytest_playwright/pytest_playwright.py +++ b/pytest-playwright/pytest_playwright/pytest_playwright.py @@ -89,7 +89,8 @@ def delete_output_dir(pytestconfig: Any) -> None: def pytest_generate_tests(metafunc: Any) -> None: if "browser_name" in metafunc.fixturenames: browsers = metafunc.config.option.browser or ["chromium"] - metafunc.parametrize("browser_name", browsers, scope="session") + if "browser_name" not in getattr(metafunc, "params", {}): + metafunc.parametrize("browser_name", browsers, scope="session") def pytest_configure(config: Any) -> None: