Пример #1
0
def test_patch_contextmanager_with_another_hostname():
    with patch_gethostbyname({"localhost2": "1.2.3.4"}):
        assert socket.gethostbyname("localhost") == "127.0.0.1"
Пример #2
0
def test_patch_contextmanager_with_unknown_hostname():
    with patch_gethostbyname({"UNKNOWN_HOST_AZ": "127.0.0.1"}):
        assert socket.gethostbyname("UNKNOWN_HOST_AZ") == "127.0.0.1"
Пример #3
0
def test_patch_contextmanager_with_public_fqdn_and_a_name_for_addr():
    with patch_gethostbyname({"example.org": "localhost"}):
        assert socket.gethostbyname("example.org") == "127.0.0.1"
Пример #4
0
def test_patch_contextmanager_with_public_fqdn():
    with patch_gethostbyname({"example.org": "1.2.3.4"}):
        assert socket.gethostbyname("example.org") == "1.2.3.4"
Пример #5
0
def test_patch_contextmanager_with_ip():
    with patch_gethostbyname({"127.0.0.1": "1.2.3.4"}):
        assert socket.gethostbyname("127.0.0.1") == "1.2.3.4"
Пример #6
0
def test_patch_contextmanager_with_name():
    with patch_gethostbyname({"localhost": "1.2.3.4"}):
        assert socket.gethostbyname("localhost") == "1.2.3.4"