Botright
Botright copied to clipboard
[BUG] offline tests fail
Botright should not depend on being online for tests wich do not require an internet connection
Example exception:
tests\test_playwright.py:95 (test_canvas_botright)
@pytest.mark.asyncio
async def test_canvas_botright():
botright_client = await botright.Botright(use_undetected_playwright=True, user_action_layer=True)
try:
> browser = await botright_client.new_browser(channel="chrome")
tests\test_playwright.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv\lib\site-packages\botright\botright.py:147: in new_browser
_proxy: ProxyManager = await ProxyManager(self, proxy)
.venv\lib\site-packages\async_class.py:173: in __await__
yield from self.create_task(
.venv\lib\site-packages\botright\modules\proxy_manager.py:68: in __ainit__
await self.check_proxy(self._phttpx)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <botright.modules.proxy_manager.ProxyManager object at 0x00000245FA3CEE80>
httpx_client = <httpx.AsyncClient object at 0x00000245FA316B90>
async def check_proxy(self, httpx_client: httpx.AsyncClient) -> None:
"""
Check the validity of the proxy by making HTTP requests to determine its properties.
Args:
httpx_client (httpx.AsyncClient): The HTTPX client to use for proxy checks.
"""
get_ip_apis = ["https://api.ipify.org/?format=json", "https://api.myip.com/", "https://get.geojs.io/v1/ip.json", "https://api.ip.sb/jsonip", "https://l2.io/ip.json"]
for get_ip_api in get_ip_apis:
try:
ip_request = await httpx_client.get(get_ip_api, timeout=self.timeout)
ip = ip_request.json().get("ip")
break
except Exception:
pass
else:
> raise ProxyCheckError("Could not get IP-Address of Proxy (Proxy is Invalid/Timed Out)")
E botright.modules.proxy_manager.ProxyCheckError: Could not get IP-Address of Proxy (Proxy is Invalid/Timed Out)
.venv\lib\site-packages\botright\modules\proxy_manager.py:123: ProxyCheckError