Patching test_get_ip attempt 2 (#2810)

* ip-patch-2

* formatting

* patch 2
This commit is contained in:
Abubakar Abid 2022-12-13 20:30:47 -06:00 committed by GitHub
parent b492212c02
commit 5182460886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -17,6 +17,8 @@ No changes to highlight.
## Full Changelog:
* Fixed typo in parameter `visible` in classes in `templates.py` by [@abidlabs](https://github.com/abidlabs) in [PR 2805](https://github.com/gradio-app/gradio/pull/2805)
* Switched external service for getting IP address from `https://api.ipify.org` to `https://checkip.amazonaws.com/` by [@abidlabs](https://github.com/abidlabs) in [PR 2810](https://github.com/gradio-app/gradio/pull/2810)
## Contributors Shoutout:
No changes to highlight.

View File

@ -78,8 +78,11 @@ def version_check():
def get_local_ip_address() -> str:
"""Gets the public IP address or returns the string "No internet connection" if unable to obtain it."""
try:
ip_address = requests.get("https://api.ipify.org", timeout=3).text
ip_address = requests.get(
"https://checkip.amazonaws.com/", timeout=3
).text.strip()
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
ip_address = "No internet connection"
return ip_address

View File

@ -103,6 +103,7 @@ class TestUtils:
class TestIPAddress:
@pytest.mark.flaky
def test_get_ip(self):
ip = get_local_ip_address()
if ip == "No internet connection":