使用加载 xmlrpclib 的插件运行 py.test 时,测试运行失败:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/main.py", line 70, in wrap_session
INTERNALERROR> config.pluginmanager.do_configure(config)
INTERNALERROR> File "/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py", line 267, in do_configure
INTERNALERROR> config.hook.pytest_configure(config=self._config)
INTERNALERROR> File "/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py",line 421, in call
INTERNALERROR> return self._docall(methods, kwargs)
INTERNALERROR> File "/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py",line 432, in _docall INTERNALERROR> res = mc.execute()
INTERNALERROR> File "/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py",line 350, in execute
INTERNALERROR> res = method(**kwargs)
INTERNALERROR> File "/Library/Python/2.7/site-packages/pytest_marker_bugzilla-0.01-py2.7.egg/pytest_marker_bugzilla.py",line 94, in pytest_configure
INTERNALERROR> bz = bugzilla.Bugzilla(url=url)
INTERNALERROR> File "build/bdist.macosx-10.7-intel/egg/bugzilla/init.py", line 75, in init
INTERNALERROR> c = getBugzillaClassForURL(kwargs['url'])
INTERNALERROR> File "build/bdist.macosx-10.7-intel/egg/bugzilla/init.py", line 26, in getBugzillaClassForURL
INTERNALERROR> s = xmlrpclib.ServerProxy(url)
INTERNALERROR> File "build/bdist.macosx-10.7-intel/egg/xmlrpclib.py", line 1215, in init
INTERNALERROR> raise IOError, "unsupported XML-RPC protocol"
INTERNALERROR> > > IOError: unsupported XML-RPC protocol
我已经验证 xmlrpclib 可以与一个简单的测试程序一起使用,该程序从图片中删除 py.test。
#!/usr/bin/env python
import xmlrpclib
import bugzilla
import sys
for i in sys.path:
print i
url = 'https://bugzilla.redhat.com/xmlrpc.cgi'
u = ' '
p = ' '
try:
proxy = xmlrpclib.ServerProxy(url)
except(), e:
print e
b = bugzilla.Bugzilla(url=url)
b.login(u,p)
bug = b.getbugsimple('12345')
print bug
上面的程序执行后会按预期返回。我对这里发生的事情感到茫然。我什至将 print sys.path 添加到了 py.test 和上面的测试程序中,发现除了执行目录/Users/esammons 和/usr/local/bin 之外,路径是相同的py.测试。
为了进一步排除问题,我将/usr/local/bin/py.test 和/usr/local/bin/py.test-2.7 复制到我的项目根目录,发生了同样的错误。
谢谢!
最佳答案
该问题是由我的 cfg 文件中的值的格式引起的。我正在使用 ConfigParser 来解析我的配置文件; cfg 文件具有以下格式。
[DEFAULT]
key = value
key2 = value
key3 = value
该问题是由于我将值用引号引起来的(“值”)。具体来说:
错误
bugzilla_url = 'https://bugzilla.example.com/xmlrpc.cgi'
右
bugzilla_url = https://bugzilla.example.com/xmlrpc.cgi
关于python - 使用 xmlrpclib 的 PyTest 插件失败并出现 IOError : "unsupported XML-RPC protocol" on Mac OS X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11024425/