Skip to content

Commit 016d073

Browse files
committed
Use contextlib.supress instead of try/except
1 parent d84f605 commit 016d073

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tests/conftest.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
import asyncio
3+
import contextlib
44
import os
55
import subprocess
66

@@ -36,14 +36,10 @@ def pytest_addoption(parser: Parser) -> None:
3636

3737
@pytest.fixture(autouse=True, scope="session")
3838
def install_playwright():
39-
subprocess.run(["playwright", "install", "chromium"], check=True) # noqa: S607, S603
39+
subprocess.run(["playwright", "install", "chromium"], check=True) # noqa: S607
4040
# Try to install system deps, but don't fail if already installed or no root access
41-
try:
42-
subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607, S603
43-
except subprocess.CalledProcessError:
44-
# Deps may already be installed (e.g., via Dockerfile) or we may not have root access
45-
# The actual browser launch will fail if deps are truly missing
46-
pass
41+
with contextlib.suppress(subprocess.CalledProcessError):
42+
subprocess.run(["playwright", "install-deps"], check=True) # noqa: S607
4743

4844

4945
@pytest.fixture(autouse=True, scope="session")
@@ -55,7 +51,7 @@ def rebuild():
5551
# passed to the subprocess.
5652
env = os.environ.copy()
5753
env.pop("HATCH_ENV_ACTIVE", None)
58-
subprocess.run(["hatch", "build", "-t", "wheel"], check=True, env=env) # noqa: S607, S603
54+
subprocess.run(["hatch", "build", "-t", "wheel"], check=True, env=env) # noqa: S607
5955

6056

6157
@pytest.fixture(autouse=True, scope="function")

0 commit comments

Comments
 (0)