test: align csp test with pathlib rooting pattern from existing suite

Use Path(__file__).resolve().parents[1] so the test survives being run
from a non-repo-root cwd, matching test_issue1112_csp_google_fonts.py.

Absorbed from PR #1852 follow-up commit 1448f42 by @ChaseFlorell.

Co-authored-by: Chase Florell <ChaseFlorell@users.noreply.github.com>
This commit is contained in:
ChaseFlorell committed 2026-05-07 21:14:16 +00:00
1 parent d703959b74
commit 9a6e7483f6
1 file changed
+4 -2
@@ -6,11 +6,13 @@ jsDelivr and are fetched via connect (not script load), so connect-src must
include cdn.jsdelivr.net or browsers block the fetch and emit CSP violations.
"""
import re
from pathlib import Path
_HELPERS_PY = Path(__file__).resolve().parents[1] / "api/helpers.py"
def _helpers_src() -> str:
with open("api/helpers.py") as f:
return f.read()
return _HELPERS_PY.read_text()
class TestCSPConnectSrcJsdelivr: