From d4e5cedb05f1ff5e54650008be7902ed27bed2b8 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 24 May 2024 22:37:51 +0800 Subject: [PATCH] feat: pytest-playwright==0.5.0 fix #7 --- pdm.lock | 8 ++++---- pyproject.toml | 3 ++- src/pytest_playwright_async/pytest_playwright_async.py | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pdm.lock b/pdm.lock index 6e8393c..f6541df 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["cross_platform"] lock_version = "4.4" -content_hash = "sha256:e24b3d0ae9aa8ba6b6290a5bc83349fa5795210db1bfb09919edea60b54c3b7e" +content_hash = "sha256:0493a27cf0543b76a08936b5fff60f91c323e7f0b915fb26129b57f5c15b8228" [[package]] name = "appnope" @@ -482,7 +482,7 @@ files = [ [[package]] name = "pytest-playwright" -version = "0.4.4" +version = "0.5.0" requires_python = ">=3.8" summary = "A pytest wrapper with fixtures for Playwright to automate web browsers" dependencies = [ @@ -492,8 +492,8 @@ dependencies = [ "python-slugify<9.0.0,>=6.0.0", ] files = [ - {file = "pytest-playwright-0.4.4.tar.gz", hash = "sha256:5488db4cc49028491c5130af0a2bb6b1d0b222a202217f6d14491d4c9aa67ff9"}, - {file = "pytest_playwright-0.4.4-py3-none-any.whl", hash = "sha256:df306f3a60a8631a3cfde1b95a2ed5a89203a3408dfa1154de049ca7de87c90b"}, + {file = "pytest-playwright-0.5.0.tar.gz", hash = "sha256:f9f5ae8ade2f773e6e2cd85ec6bfff2ab287f7943108b3956fe5971324151622"}, + {file = "pytest_playwright-0.5.0-py3-none-any.whl", hash = "sha256:b382c870384419c025d66aea14518bab71fb9e79917d4808692cde70d8c5216a"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index adca2d5..ef1d58c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,8 @@ version = "0.14.0" requires-python = ">=3.8" dependencies = [ # https://pypi.org/project/pytest-playwright/ - "pytest-playwright==0.4.4", + # https://github.com/microsoft/playwright-pytest/blob/v0.5.0/pytest_playwright/pytest_playwright.py + "pytest-playwright==0.5.0", # https://github.com/microsoft/playwright-python/blob/main/local-requirements.txt "pytest-asyncio", ] diff --git a/src/pytest_playwright_async/pytest_playwright_async.py b/src/pytest_playwright_async/pytest_playwright_async.py index 4c933a4..bdcfca8 100644 --- a/src/pytest_playwright_async/pytest_playwright_async.py +++ b/src/pytest_playwright_async/pytest_playwright_async.py @@ -1,5 +1,6 @@ import os import sys +import tempfile import typing as t from playwright.async_api import Browser @@ -14,7 +15,6 @@ from pytest_playwright.pytest_playwright import VSCODE_PYTHON_EXTENSION_ID from pytest_playwright.pytest_playwright import _build_artifact_test_folder from pytest_playwright.pytest_playwright import _is_debugger_attached -from pytest_playwright.pytest_playwright import artifacts_folder from pytest_playwright.pytest_playwright import slugify @@ -42,6 +42,7 @@ def browser_context_args_async( playwright_async: Playwright, device: t.Optional[str], base_url: t.Optional[str], + _pw_artifacts_folder: tempfile.TemporaryDirectory, ) -> t.Dict: context_args = {} if device: @@ -52,7 +53,7 @@ def browser_context_args_async( video_option = pytestconfig.getoption('--video') capture_video = video_option in ['on', 'retain-on-failure'] if capture_video: - context_args['record_video_dir'] = artifacts_folder.name + context_args['record_video_dir'] = _pw_artifacts_folder.name return context_args @@ -84,7 +85,7 @@ async def launch(**kwargs: dict) -> Browser: @pytest_asyncio.fixture(scope='session') async def browser_async( - launch_browser_async: t.Callable[..., t.Awaitable[Browser]] + launch_browser_async: t.Callable[..., t.Awaitable[Browser]], ) -> t.AsyncGenerator[Browser, None]: browser = await launch_browser_async() yield browser