[issue8857] socket.getaddrinfo needs tests

Giampaolo Rodola' report at bugs.python.org
Mon Aug 16 17:05:26 CEST 2010

Giampaolo Rodola' <g.rodola at gmail.com> added the comment:

I think the main problem here is that it's not easy to write reliable tests that work across all platforms (getaddrinfo(host, 'ftp') returning UDP addresses on FreeBSD/Qemu only is an example).
We might try to go a little deeper as you suggested but it's very likely that some buildbots turn red, IMHO.

> One example of this: test the 'family' flag by looking for 
> www.google.com with both AF_INET and AF_INET6 and then check that the 
> first returns IPv4 information and the second IPv6.

This is already done, although for IPv4 only and by using localhost instead of google.com.

        infos = socket.getaddrinfo(HOST, None, socket.AF_INET)
        for family, _, _, _, _ in infos:
            self.assertEqual(family, socket.AF_INET)

I'm attaching a new patch which adds some additional checks.
Feel free to extend it, if you want.

Added file: http://bugs.python.org/file18543/getaddrtests.patch

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list