Skip to main content

static_site_tests: allow reusing the browser fixture

ID
7870242
date
2026-02-28 10:30:02+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
14b1d8b
message
static_site_tests: allow reusing the browser fixture
changed files
3 files, 16 additions, 11 deletions

Changed files

CHANGELOG.md (3226) → CHANGELOG.md (3386)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1909781..0b46e6e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # CHANGELOG
 
+## v26 - 2026-02-28
+
+Extract the `browser` fixture as a standalone fixture rather than binding it to a class, so it can be reused across multiple test suites.
+
 ## v25 - 2026-02-28
 
 Change the type of `StaticSiteTestSuite.pages_to_check` from `set` to `list` to ensure consistent ordering of parametrised tests.

src/chives/__init__.py (391) → src/chives/__init__.py (391)

diff --git a/src/chives/__init__.py b/src/chives/__init__.py
index 68123f0..135c29d 100644
--- a/src/chives/__init__.py
+++ b/src/chives/__init__.py
@@ -11,4 +11,4 @@ I share across multiple sites.
 
 """
 
-__version__ = "25"
+__version__ = "26"

src/chives/static_site_tests.py (9853) → src/chives/static_site_tests.py (9814)

diff --git a/src/chives/static_site_tests.py b/src/chives/static_site_tests.py
index 419755e..b617eb3 100644
--- a/src/chives/static_site_tests.py
+++ b/src/chives/static_site_tests.py
@@ -266,16 +266,6 @@ class StaticSiteTestSuite[M](ABC):
     #
     # See https://github.com/microsoft/playwright-python/issues/313
 
-    @pytest.fixture(scope="session")
-    def browser(self) -> Iterator[Browser]:  # pragma: no cover
-        """
-        Launch an instance of WebKit we can interact with in tests.
-        """
-        with sync_playwright() as p:
-            browser = p.webkit.launch()
-            yield browser
-            browser.close()
-
     def test_loads_page_correctly(
         self, site_root: Path, url: str, browser: Browser
     ) -> None:  # pragma: no cover
@@ -309,3 +299,14 @@ class StaticSiteTestSuite[M](ABC):
 
         # Check there weren't any page errors
         assert page_errors == []
+
+
+@pytest.fixture(scope="session")
+def browser() -> Iterator[Browser]:  # pragma: no cover
+    """
+    Launch an instance of WebKit we can interact with in tests.
+    """
+    with sync_playwright() as p:
+        browser = p.webkit.launch()
+        yield browser
+        browser.close()