PyTest plugin using xmlrpclib fails with IOError: “unsupported XML-RPC protocol” on Mac OS X

StackOverflow https://stackoverflow.com/questions/11024425

  •  14-06-2021
  •  | 
  •  

Domanda

When running py.test using a plugin that loads xmlrpclib the test run fails with:

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

I have verified that xmlrpclib will work with a simple test program, this program removes py.test from the picture.

#!/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

The program above when executed returns as expected. I am at a loss for what is going on here. I have even added print sys.path to both py.test and the test program above and found that the paths are identical with the exception of the execute directory, /Users/esammons for the test.py and /usr/local/bin for py.test.

To further rule out issues I copied /usr/local/bin/py.test and /usr/local/bin/py.test-2.7 to my project root, same error occurred.

Thanks!

È stato utile?

Soluzione

The issue was caused by the formatting of my values in my cfg file. I'm using ConfigParser to parse my config file; the cfg file has the following format.

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

The issue was caused by my wrapping the value in quotes ('value'). Specifically:

WRONG

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

RIGHT

bugzilla_url = https://bugzilla.example.com/xmlrpc.cgi
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top