示例#1
0
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
示例#2
0
def internet_ok():
    return internet_connected()
示例#3
0
def internet_ok() -> bool:
    return internet_connected()