Python 3.4.1 测试失败:错误:test_connect_starttls (test.test_smtpnet.SmtpTest)
我刚在我的CentOS 6.4虚拟机上下载了Python 3.4.1,并按照说明书里的步骤操作。首先我运行了./configure,然后是make,接着是make test。
当我运行make test时出现了错误,我也不知道为什么,我只是严格按照说明来做的。以下是输出的内容:
test test_smtpnet failed -- Traceback (most recent call last):
File "/usr/local/Python-3.4.1/Lib/test/test_smtpnet.py", line 30, in test_connect_starttls
server = smtplib.SMTP(self.testServer, self.remotePort)
File "/usr/local/Python-3.4.1/Lib/smtplib.py", line 242, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/Python-3.4.1/Lib/smtplib.py", line 321, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/local/Python-3.4.1/Lib/smtplib.py", line 292, in _get_socket
self.source_address)
File "/usr/local/Python-3.4.1/Lib/socket.py", line 509, in create_connection
raise err
File "/usr/local/Python-3.4.1/Lib/socket.py", line 495, in create_connection
sock = socket(af, socktype, proto)
File "/usr/local/Python-3.4.1/Lib/socket.py", line 123, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol
368 tests OK.
1 test failed:
test_smtpnet
7 tests altered the execution environment:
test_calendar test_float test_locale test_site test_strptime
test_types test_warnings
12 tests skipped:
test_curses test_devpoll test_gdb test_kqueue test_msilib
test_ossaudiodev test_startfile test_tk test_ttk_guionly
test_winreg test_winsound test_zipfile64
Re-running failed tests in verbose mode
Re-running test 'test_smtpnet' in verbose mode
test_connect_starttls (test.test_smtpnet.SmtpTest) ... ERROR
test_connect (test.test_smtpnet.SmtpSSLTest) ... ok
test_connect_default_port (test.test_smtpnet.SmtpSSLTest) ... ok
test_connect_using_sslcontext (test.test_smtpnet.SmtpSSLTest) ... ok
test_connect_using_sslcontext_verified (test.test_smtpnet.SmtpSSLTest) ... ok
======================================================================
ERROR: test_connect_starttls (test.test_smtpnet.SmtpTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/Python-3.4.1/Lib/test/test_smtpnet.py", line 30, in test_connect_starttls
server = smtplib.SMTP(self.testServer, self.remotePort)
File "/usr/local/Python-3.4.1/Lib/smtplib.py", line 242, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/Python-3.4.1/Lib/smtplib.py", line 321, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/local/Python-3.4.1/Lib/smtplib.py", line 292, in _get_socket
self.source_address)
File "/usr/local/Python-3.4.1/Lib/socket.py", line 509, in create_connection
raise err
File "/usr/local/Python-3.4.1/Lib/socket.py", line 495, in create_connection
sock = socket(af, socktype, proto)
File "/usr/local/Python-3.4.1/Lib/socket.py", line 123, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol
----------------------------------------------------------------------
Ran 5 tests in 42.864s
FAILED (errors=1)
test test_smtpnet failed
make: *** [test] Error 1
看起来是_socket模块尝试使用一种“地址族”(这到底是什么东西啊)但这个协议不支持。能不能把这个错误信息说得更清楚一点?
有没有人知道我这里缺少了什么?
1 个回答
2
看起来这个测试案例确实需要启用IPv6。所以如果你的系统没有开启IPv6支持,它就会失败。你可以运行 ip a s
命令来检查虚拟机(VM)是否有设置IPv6地址,通常这个地址是以 fe80::
开头的。地址类型可以是AF_INET表示IPv4,或者AF_INET6表示IPv6。实际上,这个是测试案例的一个bug。