test: skip network/live crawl by default; fix settings e2e key

- pytest_collection_modifyitems: skip @pytest.mark.network unless PROXYPOOL_RUN_NETWORK_TESTS=1
- Document opt-in in tests/README.md
- e2e: replace removed crawl_timeout with validation_timeout

Made-with: Cursor
This commit is contained in:
祀梦
2026-04-05 14:33:29 +08:00
parent e582067316
commit ce667dba13
3 changed files with 34 additions and 12 deletions

View File

@@ -11,6 +11,26 @@ if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
import pytest
def _network_tests_enabled() -> bool:
v = os.environ.get("PROXYPOOL_RUN_NETWORK_TESTS", "").strip().lower()
return v in ("1", "true", "yes", "on")
def pytest_collection_modifyitems(config, items) -> None:
"""默认跳过 @pytest.mark.network避免全量 pytest 触发真实爬取卡住数十分种。"""
if _network_tests_enabled():
return
skip = pytest.mark.skip(
reason=(
"外网/真实爬取用例默认跳过。需要验收时设置环境变量 "
"PROXYPOOL_RUN_NETWORK_TESTS=1 后再运行对应文件或 -m network。"
)
)
for item in items:
if "network" in item.keywords:
item.add_marker(skip)
import pytest_asyncio
from typing import AsyncGenerator
from httpx import AsyncClient, ASGITransport