Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

test: skip cleanly instead of aborting collection on missing optional deps

Agrici Daniel3854391ecb9f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4252a17..26cad94 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -51,6 +51,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`save_config()` and `load_config()` make a best-effort `icacls` call on
Windows to restrict `~/.config/claude-seo/backlinks-api.json` to the
current user, since POSIX mode bits do not restrict NTFS ACLs (#290).
+- 17 scripts raise `sys.exit(1)` at import time when an optional dependency
+ (`requests`, `bs4`, `playwright`, `googleapiclient`, `google.analytics`) is
+ missing. Any test module that imports one of these at module scope aborted
+ the whole pytest session on a minimal install instead of skipping. 8 of the
+ 17 (`bing_webmaster`, `commoncrawl_graph`, `crux_history`, `fetch_page`,
+ `moz_api`, `nlp_analyze`, `pagespeed_check`, `parse_html`) had test modules
+ that needed the guard (`gsc_query`'s 3 test modules already had it; the
+ other 8 of the 17 have no test module that imports them at module scope,
+ so nothing to guard). `url_safety.py` itself hard-requires `requests`
+ (by design), so every script that imports it transitively hits the same
+ failure; guarded those test modules too (`domain_history`,
+ `gbp_deprecation_lint`, `parasite_risk`, `agent_ux_check`/`render_page`,
+ `indexnow_submit`, `url_safety`'s own suite, and the new
+ `backlinks_auth` hardening tests). 17 test modules gained a
+ `pytest.importorskip` guard in total. Verified in a throwaway venv with
+ only `pytest` and `beautifulsoup4` installed: the suite completes (206
+ passed, 24 skipped, no errors).
## [2.2.6] - 2026-09-10
diff --git a/tests/test_backlinks_auth_hardening.py b/tests/test_backlinks_auth_hardening.py
index b91d509..784c07b 100644
--- a/tests/test_backlinks_auth_hardening.py
+++ b/tests/test_backlinks_auth_hardening.py
@@ -21,6 +21,10 @@ _SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+# backlinks_auth.py unconditionally imports url_safety, which itself hard-requires
+# requests (by design: no SSRF checks is worse than none). Skip cleanly rather
+# than aborting collection when requests is not installed.
+pytest.importorskip("requests")
import backlinks_auth # noqa: E402
diff --git a/tests/test_bing_webmaster.py b/tests/test_bing_webmaster.py
index 6cd12c6..9317f2a 100644
--- a/tests/test_bing_webmaster.py
+++ b/tests/test_bing_webmaster.py
@@ -12,6 +12,7 @@ import pytest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
+pytest.importorskip("requests")
import bing_webmaster as bing # noqa: E402
diff --git a/tests/test_commoncrawl_graph.py b/tests/test_commoncrawl_graph.py
index bc12d34..7c04661 100644
--- a/tests/test_commoncrawl_graph.py
+++ b/tests/test_commoncrawl_graph.py
@@ -22,6 +22,7 @@ _SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+pytest.importorskip("requests")
import commoncrawl_graph as ccg # noqa: E402
diff --git a/tests/test_domain_history.py b/tests/test_domain_history.py
index b676a65..d6d568f 100644
--- a/tests/test_domain_history.py
+++ b/tests/test_domain_history.py
@@ -22,6 +22,7 @@ _SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+pytest.importorskip("requests")
import domain_history as dh # noqa: E402
diff --git a/tests/test_fetch_page_cli.py b/tests/test_fetch_page_cli.py
index f3912cd..a1fc30e 100644
--- a/tests/test_fetch_page_cli.py
+++ b/tests/test_fetch_page_cli.py
@@ -15,6 +15,7 @@ from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
+pytest.importorskip("requests")
import fetch_page # noqa: E402
import render_page # noqa: E402
diff --git a/tests/test_fetch_page_decoding.py b/tests/test_fetch_page_decoding.py
index 2db6f3a..64f888c 100644
--- a/tests/test_fetch_page_decoding.py
+++ b/tests/test_fetch_page_decoding.py
@@ -5,11 +5,14 @@ from __future__ import annotations
import sys
from pathlib import Path
+import pytest
+
REPO_ROOT = Path(__file__).resolve().parents[1]
SCRIPTS_DIR = REPO_ROOT / "scripts"
if str(SCRIPTS_DIR) not in sys.path:
sys.path.insert(0, str(SCRIPTS_DIR))
+pytest.importorskip("requests")
import fetch_page # noqa: E402
diff --git a/tests/test_gbp_lint_and_polish.py b/tests/test_gbp_lint_and_polish.py
index 5285c3e..75a6d65 100644
--- a/tests/test_gbp_lint_and_polish.py
+++ b/tests/test_gbp_lint_and_polish.py
@@ -10,11 +10,14 @@ from __future__ import annotations
import sys
from pathlib import Path
+import pytest
+
_REPO = Path(__file__).resolve().parents[1]
_SCRIPTS = _REPO / "scripts"
if str(_SCRIPTS) not in sys.path:
sys.path.insert(0, str(_SCRIPTS))
+pytest.importorskip("requests")
import gbp_deprecation_lint as gbp # noqa: E402
# ---------------------------------------------------------------------------
diff --git a/tests/test_google_api_key_safety.py b/tests/test_google_api_key_safety.py
index 15dc651..fdd7fcd 100644
--- a/tests/test_google_api_key_safety.py
+++ b/tests/test_google_api_key_safety.py
@@ -12,13 +12,14 @@ import sys
from types import SimpleNamespace
from unittest.mock import patch
-import requests
+import pytest
_SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "scripts")
_REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+requests = pytest.importorskip("requests")
import crux_history # noqa: E402
import google_auth # noqa: E402
import lcp_subparts # noqa: E402
diff --git a/tests/test_lazy_detection.py b/tests/test_lazy_detection.py
index 46c7689..af07783 100644
--- a/tests/test_lazy_detection.py
+++ b/tests/test_lazy_detection.py
@@ -9,10 +9,16 @@ alone reports "not lazy-loaded" when the page is heavily lazy-loaded.
import sys
from pathlib import Path
+import pytest
+
# Make scripts/ importable without requiring it to be a package
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
+pytest.importorskip("bs4")
+# parse_html.py also unconditionally imports url_safety, which itself
+# hard-requires requests.
+pytest.importorskip("requests")
from bs4 import BeautifulSoup # noqa: E402
from parse_html import _detect_lazy_method, parse_html # noqa: E402
diff --git a/tests/test_moz_api.py b/tests/test_moz_api.py
index 831539c..6a65feb 100644
--- a/tests/test_moz_api.py
+++ b/tests/test_moz_api.py
@@ -7,10 +7,13 @@ import os
import sys
from unittest.mock import patch
+import pytest
+
_SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "scripts")
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+pytest.importorskip("requests")
import backlinks_auth # noqa: E402
import moz_api # noqa: E402
diff --git a/tests/test_nlp_analyze.py b/tests/test_nlp_analyze.py
index b30c02b..a77df96 100644
--- a/tests/test_nlp_analyze.py
+++ b/tests/test_nlp_analyze.py
@@ -6,10 +6,13 @@ import os
import sys
from unittest.mock import patch
+import pytest
+
_SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "scripts")
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+pytest.importorskip("requests")
import nlp_analyze # noqa: E402
diff --git a/tests/test_pagespeed_null_category_score.py b/tests/test_pagespeed_null_category_score.py
index 53c1333..2fd4401 100644
--- a/tests/test_pagespeed_null_category_score.py
+++ b/tests/test_pagespeed_null_category_score.py
@@ -11,9 +11,12 @@ import sys
from pathlib import Path
from unittest import mock
+import pytest
+
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
+pytest.importorskip("requests")
import pagespeed_check # noqa: E402
diff --git a/tests/test_parasite_risk_and_extensions.py b/tests/test_parasite_risk_and_extensions.py
index 349ea98..2b97654 100644
--- a/tests/test_parasite_risk_and_extensions.py
+++ b/tests/test_parasite_risk_and_extensions.py
@@ -19,6 +19,7 @@ _SCRIPTS = _REPO_ROOT / "scripts"
if str(_SCRIPTS) not in sys.path:
sys.path.insert(0, str(_SCRIPTS))
+pytest.importorskip("requests")
import parasite_risk # noqa: E402
# ---------------------------------------------------------------------------
diff --git a/tests/test_phase_j_executable.py b/tests/test_phase_j_executable.py
index 95b3bde..832ef6d 100644
--- a/tests/test_phase_j_executable.py
+++ b/tests/test_phase_j_executable.py
@@ -17,11 +17,14 @@ import sys
from pathlib import Path
from unittest import mock
+import pytest
+
_REPO_ROOT = Path(__file__).resolve().parents[1]
_SCRIPTS = _REPO_ROOT / "scripts"
if str(_SCRIPTS) not in sys.path:
sys.path.insert(0, str(_SCRIPTS))
+pytest.importorskip("requests")
import agent_ux_check # noqa: E402
import iptc_ai_label # noqa: E402
import render_page # noqa: E402
diff --git a/tests/test_render_page.py b/tests/test_render_page.py
index 9c34c35..9031403 100644
--- a/tests/test_render_page.py
+++ b/tests/test_render_page.py
@@ -30,6 +30,7 @@ _SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+pytest.importorskip("requests")
import render_page # noqa: E402
# ---------------------------------------------------------------------------
diff --git a/tests/test_technical_depth.py b/tests/test_technical_depth.py
index c47031a..810fc3a 100644
--- a/tests/test_technical_depth.py
+++ b/tests/test_technical_depth.py
@@ -20,10 +20,13 @@ import sys
from types import SimpleNamespace
from unittest.mock import patch
+import pytest
+
_SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "scripts")
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+pytest.importorskip("requests")
import indexnow_submit # noqa: E402
import lcp_subparts # noqa: E402
import preload_check # noqa: E402
diff --git a/tests/test_url_safety.py b/tests/test_url_safety.py
index da6f467..3d9fd4a 100644
--- a/tests/test_url_safety.py
+++ b/tests/test_url_safety.py
@@ -25,6 +25,7 @@ _SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__
if _SCRIPTS not in sys.path:
sys.path.insert(0, _SCRIPTS)
+pytest.importorskip("requests")
import url_safety # noqa: E402
# ---------------------------------------------------------------------------