Debian Codegraph @

debian/patches/0005-tests-without-playwright.patch

raw
1 From: Colin Watson <[email protected]>
2 Date: Sun, 27 Sep 2026 00:47:05 +0100
3 Subject: Allow running test suite without playwright
4
5 python3-playwright currently isn't in Debian testing.
6
7 Last-Update: 2026-09-27
8 ---
9 conftest.py | 17 -----------------
10 src/polymorphic/tests/test_admin.py | 7 +++++--
11 src/polymorphic/tests/utils.py | 7 ++++++-
12 3 files changed, 11 insertions(+), 20 deletions(-)
13
14 diff --git a/conftest.py b/conftest.py
15 index a3313a1..aaf7412 100644
16 --- a/conftest.py
17 +++ b/conftest.py
18 @@ -1,8 +1,4 @@
19 import inspect
20 -import subprocess
21 -import sys
22 -
23 -import pytest
24
25
26 def pytest_configure(config):
27 @@ -59,16 +55,3 @@ def pytest_runtest_call(item):
28 dbg.set_trace()
29 except (OSError, AssertionError):
30 pass
31 -
32 -
33 -def _install_playwright_browsers() -> None:
34 - cmd = [sys.executable, "-m", "playwright", "install", "chromium"]
35 - subprocess.run(cmd, check=True)
36 -
37 -
38 -def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]) -> None:
39 - any_ui = any(item.get_closest_marker("ui") is not None for item in items)
40 -
41 - if any_ui and not getattr(config, "_did_install_playwright", False):
42 - setattr(config, "_did_install_playwright", True)
43 - _install_playwright_browsers()
44 diff --git a/src/polymorphic/tests/test_admin.py b/src/polymorphic/tests/test_admin.py
45 index 8cdc76e..5daf596 100644
46 --- a/src/polymorphic/tests/test_admin.py
47 +++ b/src/polymorphic/tests/test_admin.py
48 @@ -5,7 +5,6 @@ from django.contrib.contenttypes.models import ContentType
49 from django.utils.html import escape
50 from django.test import RequestFactory
51 from django.urls import resolve
52 -from playwright._impl._errors import TargetClosedError
53 from polymorphic.admin import (
54 GenericStackedPolymorphicInline,
55 PolymorphicChildModelAdmin,
56 @@ -33,7 +32,11 @@ from polymorphic.tests.models import (
57 PolymorphicTagB,
58 )
59
60 -from playwright.sync_api import expect
61 +try:
62 + from playwright._impl._errors import TargetClosedError
63 + from playwright.sync_api import expect
64 +except ImportError:
65 + pass
66 from urllib.parse import urljoin
67
68 from .utils import _GenericUITest
69 diff --git a/src/polymorphic/tests/utils.py b/src/polymorphic/tests/utils.py
70 index 5599905..4e127e3 100644
71 --- a/src/polymorphic/tests/utils.py
72 +++ b/src/polymorphic/tests/utils.py
73 @@ -13,7 +13,11 @@ from django.db import connections
74 from django.urls import reverse
75 from django.apps import apps
76
77 -from playwright.sync_api import sync_playwright, expect
78 +try:
79 + from playwright.sync_api import sync_playwright, expect
80 + PLAYWRIGHT = True
81 +except ImportError:
82 + PLAYWRIGHT = False
83 from polymorphic import tests
84
85
86 @@ -158,6 +162,7 @@ class GeneratedMigrationsPerClassMixin:
87 return candidates[-1].stem
88
89
90 [email protected](not PLAYWRIGHT, reason="playwright is not available")
91 class _GenericUITest(StaticLiveServerTestCase):
92 """Generic admin form test using Playwright."""
93