wabot/tests/integration/conftest.py
Mathew Sir Guest the best 154344e94a refactor: rename sessions submodule to _sessions to avoid shadowing sessions()
wabot/__init__.py defines def sessions(...) and also had a sessions.py
submodule, so wabot.sessions (attribute) resolved to the function,
shadowing the module for import wabot.sessions as m style access. This
is the same class of collision that browser.py -> _browser.py already
fixed. Renaming to _sessions.py removes the ambiguity and lets
docs/api.rst drop the :no-index: Sphinx workaround in favor of plain
autoclass directives on the public SessionRecord/SessionStore
re-exports.
2026-07-12 15:37:56 -06:00

42 lines
1.2 KiB
Python

"""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 import SessionStore
return SessionStore(path=tmp_path / "sessions.json")