MCPcopy
hub / github.com/urllib3/urllib3 / test_create_connection_with_scoped_ipv6

Method test_create_connection_with_scoped_ipv6

test/test_util.py:904–924  ·  view source on GitHub ↗
(
        self, socket: MagicMock, getaddrinfo: MagicMock
    )

Source from the content-addressed store, hash-verified

902 @patch("socket.getaddrinfo")
903 @patch("socket.socket")
904 def test_create_connection_with_scoped_ipv6(
905 self, socket: MagicMock, getaddrinfo: MagicMock
906 ) -> None:
907 # Check that providing create_connection with a scoped IPv6 address
908 # properly propagates the scope to getaddrinfo, and that the returned
909 # scoped ID makes it to the socket creation call.
910 fake_scoped_sa6 = ("a::b", 80, 0, 42)
911 getaddrinfo.return_value = [
912 (
913 socket.AF_INET6,
914 socket.SOCK_STREAM,
915 socket.IPPROTO_TCP,
916 "",
917 fake_scoped_sa6,
918 )
919 ]
920 socket.return_value = fake_sock = MagicMock()
921
922 create_connection(("a::b%iface", 80))
923 assert getaddrinfo.call_args[0][0] == "a::b%iface"
924 fake_sock.connect.assert_called_once_with(fake_scoped_sa6)
925
926 @pytest.mark.parametrize(
927 "input,params,expected",

Callers

nothing calls this directly

Calls 1

create_connectionFunction · 0.90

Tested by

no test coverage detected