From d84f605fca02bbdf0a945dafbd562bd76f299719 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Wed, 10 Dec 2025 15:56:07 +0000 Subject: [PATCH 1/2] Fix: tests failing when 'playwright install-deps' has already been done as part of the host/container provisioning. --- tests/conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1d133fd6b..1ef107aa7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,7 +37,13 @@ def pytest_addoption(parser: Parser) -> None: @pytest.fixture(autouse=True, scope="session") def install_playwright(): subprocess.run(["playwright", "install", "chromium"], check=True) # noqa: S607, S603 - subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607, S603 + # Try to install system deps, but don't fail if already installed or no root access + try: + subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607, S603 + except subprocess.CalledProcessError: + # Deps may already be installed (e.g., via Dockerfile) or we may not have root access + # The actual browser launch will fail if deps are truly missing + pass @pytest.fixture(autouse=True, scope="session") From 016d0731a9911fdb413f8f97a7e0d17bce14b1d0 Mon Sep 17 00:00:00 2001 From: Archmonger <16909269+Archmonger@users.noreply.github.com> Date: Wed, 10 Dec 2025 14:02:44 -0800 Subject: [PATCH 2/2] Use contextlib.supress instead of try/except --- tests/conftest.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1ef107aa7..167a85b26 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ from __future__ import annotations -import asyncio +import contextlib import os import subprocess @@ -36,14 +36,10 @@ def pytest_addoption(parser: Parser) -> None: @pytest.fixture(autouse=True, scope="session") def install_playwright(): - subprocess.run(["playwright", "install", "chromium"], check=True) # noqa: S607, S603 + subprocess.run(["playwright", "install", "chromium"], check=True) # noqa: S607 # Try to install system deps, but don't fail if already installed or no root access - try: - subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607, S603 - except subprocess.CalledProcessError: - # Deps may already be installed (e.g., via Dockerfile) or we may not have root access - # The actual browser launch will fail if deps are truly missing - pass + with contextlib.suppress(subprocess.CalledProcessError): + subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607 @pytest.fixture(autouse=True, scope="session") @@ -55,7 +51,7 @@ def rebuild(): # passed to the subprocess. env = os.environ.copy() env.pop("HATCH_ENV_ACTIVE", None) - subprocess.run(["hatch", "build", "-t", "wheel"], check=True, env=env) # noqa: S607, S603 + subprocess.run(["hatch", "build", "-t", "wheel"], check=True, env=env) # noqa: S607 @pytest.fixture(autouse=True, scope="function")