Vinyzu / Vinyzu/Botright

[BUG] offline tests fail

Open
#130 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
Python
Stars
1k
Forks
85
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/test_playwright.py, especially test_canvas_botright, and inspect the ProxyManager.check_proxy path shown in the traceback. Determine why this test performs external IP checks despite not requiring internet access. Done means offline tests that do not require networking no longer raise ProxyCheckError.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.