IPv6 not necessarly present if socket.AF_INET6 is defined #2104
Closed
Description
Long story short
Was trying to run the test on Python 3.5 and failed because I don't have IPv6 in a Docker container by default and the test thought I had.
root@bbbf05804213:/src# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
22: eth0@if23: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.2/16 scope global eth0
valid_lft forever preferred_lft forever
root@bbbf05804213:/src# python
Python 3.5.3 (default, Jul 8 2017, 05:09:47)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.AF_INET6
<AddressFamily.AF_INET6: 10>
Expected behaviour
Use IPv4 if IPv6 is not present.
Actual behaviour
According to the doc:
If the AF_UNIX constant is not defined then this protocol is unsupported.
This probably means that the CPython has been compiled with IPv6, not that all the network interfaces have it.
Steps to reproduce
# in aiohttp source directory
$ docker run -it --rm -v $PWD:/src -w /src python:3.5 /bin/bash
$ pip install tox
$ tox -e py35 -- -x tests/test_run_app.py
Your environment
Python 3.5.3, Docker 17.05.0-ce build 89658bed64