From 7539a5c66003927cd898e6fd60e27669a89bfa9b Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 27 May 2025 14:58:04 -0700 Subject: [PATCH] test: fix Chromium tests on Windows --- tests/test_asyncio.py | 9 +++++++++ tests/test_sync.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index bea60db..ca3e341 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -20,6 +20,15 @@ import pytest +@pytest.fixture +def pytester(pytester: pytest.Pytester) -> pytest.Pytester: + # Pytester internally in their constructor overrides the HOME and USERPROFILE env variables. This confuses Chromium hence we unset them. + # See https://github.com/pytest-dev/pytest/blob/83536b4b0074ca35d90933d3ad46cb6efe7f5145/src/_pytest/pytester.py#L704-L705 + os.environ.pop("HOME", None) + os.environ.pop("USERPROFILE", None) + return pytester + + @pytest.fixture(autouse=True) def _add_async_marker(testdir: pytest.Testdir) -> None: testdir.makefile( diff --git a/tests/test_sync.py b/tests/test_sync.py index 0f640b6..9d22b9c 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -21,6 +21,15 @@ import pytest +@pytest.fixture +def pytester(pytester: pytest.Pytester) -> pytest.Pytester: + # Pytester internally in their constructor overrides the HOME and USERPROFILE env variables. This confuses Chromium hence we unset them. + # See https://github.com/pytest-dev/pytest/blob/83536b4b0074ca35d90933d3ad46cb6efe7f5145/src/_pytest/pytester.py#L704-L705 + os.environ.pop("HOME", None) + os.environ.pop("USERPROFILE", None) + return pytester + + @pytest.fixture(autouse=True) def _add_ini(testdir: pytest.Testdir) -> None: testdir.makefile(