From 8682ec28fecbe671e14eb59345fab80976936ba0 Mon Sep 17 00:00:00 2001 From: Mathew Sir Guest the best Date: Wed, 8 Jul 2026 22:35:14 -0600 Subject: [PATCH] =?UTF-8?q?test:=20integration=20fixtures=20=E2=80=94=20st?= =?UTF-8?q?atic=20site=20server,=20auto-marking=20conftest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/fixtures/login.html | 17 ++++++++++++++ tests/fixtures/welcome.html | 8 +++++++ tests/integration/conftest.py | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 tests/fixtures/login.html create mode 100644 tests/fixtures/welcome.html create mode 100644 tests/integration/conftest.py diff --git a/tests/fixtures/login.html b/tests/fixtures/login.html new file mode 100644 index 0000000..fc271be --- /dev/null +++ b/tests/fixtures/login.html @@ -0,0 +1,17 @@ + + +Login + +

Test Login

+
+ + + + +
+ + diff --git a/tests/fixtures/welcome.html b/tests/fixtures/welcome.html new file mode 100644 index 0000000..b68c661 --- /dev/null +++ b/tests/fixtures/welcome.html @@ -0,0 +1,8 @@ + + +Welcome + +

Welcome!

+

You made it.

+ + diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py new file mode 100644 index 0000000..abfa883 --- /dev/null +++ b/tests/integration/conftest.py @@ -0,0 +1,43 @@ +"""Shared fixtures for real-browser integration tests. + +Every test in this directory is marked ``integration`` automatically and +runs with NoPacing (human delays would make the suite glacial). Browsers +run headless against static HTML served from tests/fixtures. +""" + +import functools +import http.server +import threading +from pathlib import Path + +import pytest + +FIXTURES = Path(__file__).parent.parent / "fixtures" +BROWSERS = ["firefox", "chromium"] + + +def pytest_collection_modifyitems(items): + integration_dir = Path(__file__).parent + for item in items: + if integration_dir in item.path.parents: + item.add_marker(pytest.mark.integration) + + +@pytest.fixture(scope="session") +def site_url(): + """Serve tests/fixtures over HTTP on an ephemeral port.""" + handler = functools.partial( + http.server.SimpleHTTPRequestHandler, directory=str(FIXTURES) + ) + server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + yield f"http://127.0.0.1:{server.server_address[1]}" + server.shutdown() + + +@pytest.fixture +def store(tmp_path): + from wabot.sessions import SessionStore + + return SessionStore(path=tmp_path / "sessions.json")