2012-06-13 25 views
1

當py.test使用插件加載的xmlrpclib試車運行失敗:PyTest插件失敗,IO錯誤:在Mac OS X「不支持的XML-RPC協議」

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 

上面的程序在執行時會按預期返回。我對這裏發生的事情感到不知所措。我甚至在py.test和上面的測試程序中都添加了print sys.path,並且發現路徑與test.py和/ usr/local/bin的執行目錄/ Users/esammons的例外相同py.test。

爲了進一步排除我將/usr/local/bin/py.test和/usr/local/bin/py.test-2.7複製到項目根目錄的問題,也發生了同樣的錯誤。

謝謝!

回答

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 
+0

同樣使用發生在我詹金斯和[EnvInject插件](https://wiki.jenkins-ci.org/display/JENKINS/EnvInject +插件) –