Home - Summaries: (main) : (py3.11) : (py3.12) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

pypy/module/_socket/test/test_sock_app.py::test_getaddrinfo

space = StdObjSpace
w_socket = <pypy.module._socket.moduledef.Module object at 0x0000022213f7d1a0>

    def test_getaddrinfo(space, w_socket):
        host = b"localhost"
        port = 25
        info = socket.getaddrinfo(host, port)
        w_l = space.appexec([w_socket, space.newbytes(host), space.wrap(port)],
                            "(_socket, host, port): return _socket.getaddrinfo(host, port)")
        assert space.unwrap(w_l) == info
        w_l = space.appexec([w_socket, space.wrap(host), space.wrap(port)],
                            "(_socket, host, port): return _socket.getaddrinfo(host, port)")
        assert space.unwrap(w_l) == info
        w_l = space.appexec([w_socket, space.newbytes(host), space.wrap('smtp')],
                            "(_socket, host, port): return _socket.getaddrinfo(host, port)")
        assert space.unwrap(w_l) == socket.getaddrinfo(host, 'smtp')
        w_l = space.appexec([w_socket, space.newbytes(host), space.wrap(u'\uD800')], '''
    
           (_socket, host, port):
                try:
                    info = _socket.getaddrinfo(host, port)
                except Exception as e:
                    return e.reason == 'surrogates not allowed'
                return -1
            ''')
        assert space.unwrap(w_l) == True
        # an int port outside the C long range is not an OverflowError
        w_l = space.appexec([w_socket], """(_socket):
                try:
                    _socket.getaddrinfo(None, 2**64, type=_socket.SOCK_STREAM)
                except _socket.gaierror:
                    return 1
                return 0
            """)
>       assert space.int_w(w_l) == 1
E       assert 0 == 1
E        +  where 0 = <bound method StdObjSpace.int_w of StdObjSpace>(W_IntObject(0))
E        +    where <bound method StdObjSpace.int_w of StdObjSpace> = StdObjSpace.int_w

module\_socket\test\test_sock_app.py:224: AssertionError
builder: own-win-x86-64 build #2420+
test: pypy/module/_socket/test/test_sock_app.py::test_getaddrinfo