def test_internet_connected(monkeypatch, connected: bool) -> None: def request(*args: Any, **kwargs: Any) -> None: if not connected: raise socket.gaierror(0) monkeypatch.setattr(http.client.HTTPConnection, "request", request) assert internet_connected() is connected
def internet_ok(): return internet_connected()
def internet_ok() -> bool: return internet_connected()