def test_get_ip_without_internet(self, mock_get): mock_get.side_effect = requests.ConnectionError() ip = networking.get_local_ip_address() self.assertEqual(ip, "No internet connection")
import webbrowser import inspect import sys import weakref import analytics import numpy as np import os import copy import markdown2 import json import csv from getpass import getpass analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy" analytics_url = 'https://api.gradio.app/' ip_address = networking.get_local_ip_address() JSON_PATH = os.path.join(os.path.dirname(gradio.__file__), "launches.json") class Interface: """ Interfaces are created with Gradio using the `gradio.Interface()` function. """ instances = weakref.WeakSet() @classmethod def get_instances(cls): """ :return: list of all current instances. """
def test_get_ip(self): ip = networking.get_local_ip_address() try: # check whether ip is valid ipaddress.ip_address(ip) except ValueError: self.fail("Invalid IP address")