-
-
Notifications
You must be signed in to change notification settings - Fork 306
Fix test failures: mock DNS resolution and tag Selenium tests #5276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes test failures that occur in isolated environments by mocking DNS resolution and properly tagging Selenium tests for exclusion from the main CI pipeline. The changes ensure all 305 tests can pass without requiring network access or ChromeDriver installation during CI runs.
Key Changes:
- Added DNS resolution mocking to
rebuild_safe_urltests to prevent failures whensocket.getaddrinfo()is blocked in isolated test environments - Tagged Selenium test class with
@tag("selenium", "slow")to enable exclusion via--exclude-tag=seleniumflag
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| website/tests/test_api.py | Added @patch decorator to mock socket.getaddrinfo in test_rebuild_safe_url, returning a public IP address (93.184.216.34) to simulate successful DNS resolution for example.com |
| website/tests/test_main.py | Added tag import from django.test and applied @tag("selenium", "slow") decorator to MySeleniumTests class to prevent ChromeDriver-related failures in CI |
Tests were failing due to DNS resolution attempts in isolated environments and untagged Selenium tests attempting to run in CI.
Changes
rebuild_safe_url()validates URLs by resolving hostnames viasocket.getaddrinfo(), which fails in isolated test environments. Added mock to return a public IP for test URLs.@tag("selenium", "slow")toMySeleniumTestsclass to prevent ChromeDriver download failures when tests run with--exclude-tag=selenium.All 305 tests now pass.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.openai.com/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium(dns block)/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium get --local y rt site import sbash(dns block)example.com/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium(dns block)/usr/bin/python3 python3(dns block)/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test website.tests.test_api.RebuildSafeUrlTestCase.test_rebuild_safe_url --failfast(dns block)googlechromelabs.github.io/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium(dns block)https://api.github.com/repos/TestOrg/TestRepo/issues/123/comments/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium(http block)/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium get --local y rt site import sbash(http block)https://api.github.com/repos/TestOrg/TestRepo/issues/123/labels/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium(http block)/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test --failfast --exclude-tag=selenium get --local y rt site import sbash(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.