使用xmlrpclib的PyTest插件失败,出现IOError:Mac OS X上的“不支持的XML-RPC协议”

时间:2012-06-13 22:46:40

标签: python macos xmlrpclib

使用加载xmlrpclib的插件运行py.test时,测试运行失败,并显示:

  

InternalError该>追溯(最近的呼叫最后):
  InternalError该>文件“/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/main.py”,第70行,在wrap_session中   InternalError该> config.pluginmanager.do_configure(配置)
  InternalError该>文件“/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py”,第267行,在do_configure中   InternalError该> config.hook.pytest_configure(CONFIG = self._config)
  InternalError该>文件“/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py",line 421,在致电
  InternalError该> return self._docall(methods,kwargs)
  InternalError该>在_docall中输入文件“/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py",line 432   InternalError该> res = mc.execute()
  InternalError该>文件“/Library/Python/2.7/site-packages/pytest-2.2.4-py2.7.egg/_pytest/core.py",line 350,执行中
  InternalError该> res =方法(** kwargs)
  InternalError该>文件“/Library/Python/2.7/site-packages/pytest_marker_bugzilla-0.01-py2.7.egg/pytest_marker_bugzilla.py",line 94,pytest_configure
  InternalError该> bz = bugzilla.Bugzilla(url = url)
  InternalError该>在 init 中输入文件“build / bdist.macosx-10.7-intel / egg / bugzilla / init .py”,第75行   InternalError该> c = getBugzillaClassForURL(kwargs ['url'])
  InternalError该>在getBugzillaClassForURL中输入文件“build / bdist.macosx-10.7-intel / egg / bugzilla / init .py”,第26行   InternalError该> s = xmlrpclib.ServerProxy(url)
  InternalError该>文件“build / bdist.macosx-10.7-intel / egg / xmlrpclib.py”,第1215行,在 init 中   InternalError该>提出IOError,“不支持的XML-RPC协议”
  InternalError该> > > IOError:不支持的XML-RPC协议

我已经验证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

执行时上面的程序按预期返回。我对这里发生的事情感到茫然。我甚至在上面的py.test和测试程序中添加了print sys.path,发现路径是相同的,除了执行目录,/ users / esammons用于test.py和/ usr / local / bin py.test。

为了进一步排除我将/usr/local/bin/py.test和/usr/local/bin/py.test-2.7复制到我的项目根目录的问题,发生了同样的错误。

谢谢!

1 个答案:

答案 0 :(得分:3)

问题是由我的cfg文件中的值格式化引起的。我正在使用ConfigParser来解析我的配置文件; cfg文件格式如下。

[DEFAULT]
key = value
key2 = value
key3 = value

问题是由于我将值包装在引号('value')中引起的。具体做法是:

WRONG

bugzilla_url = 'https://bugzilla.example.com/xmlrpc.cgi'

RIGHT

bugzilla_url = https://bugzilla.example.com/xmlrpc.cgi