File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121from .endpoints .geolocation import ClassGeolocation
2222
2323
24- def _pick_https_proxy () -> str | None :
25- """Возвращает прокси из HTTPS_PROXY/https_proxy (если заданы)."""
26- return os .getenv ("HTTPS_PROXY" ) or os .getenv ("https_proxy" )
27-
28-
2924@dataclass
3025class ChizhikAPI (ApiParent ):
3126 """
@@ -36,7 +31,7 @@ class ChizhikAPI(ApiParent):
3631 """Время ожидания ответа от сервера в миллисекундах."""
3732 headless : bool = True
3833 """Запускать браузер в headless режиме?"""
39- proxy : str | dict | None = field (default_factory = _pick_https_proxy )
34+ proxy : str | dict | None = field (default_factory = Proxy . from_env )
4035 """Прокси-сервер для всех запросов (если нужен). По умолчанию берет из окружения (если есть).
4136 Принимает как формат Playwright, так и строчный формат."""
4237 browser_opts : dict [str , Any ] = field (default_factory = dict )
Original file line number Diff line number Diff line change @@ -21,25 +21,6 @@ def anyio_backend():
2121 return "asyncio"
2222
2323
24- async def test_proxy_ip ():
25- from chizhik_api .manager import _pick_https_proxy
26-
27- proxy = _pick_https_proxy ()
28-
29- if not proxy :
30- pytest .skip ("Proxy not configured" )
31-
32- prx = Proxy (proxy )
33-
34- async with aiohttp .ClientSession () as session :
35- async with session .get ("http://httpbin.org/ip" , proxy = prx .as_str ()) as resp :
36- ip = (await resp .json ())["origin" ]
37-
38- assert (
39- ip == prx ._server .removeprefix ("http://" ).removeprefix ("https://" ).split (":" )[0 ]
40- )
41-
42-
4324@pytest .fixture (scope = "session" )
4425async def api ():
4526 """Фикстура для инициализации API в рамках сессии."""
You can’t perform that action at this time.
0 commit comments