I had been working on DjangoPyPI and trying to fix some tests related to XML-RPC that were failing in versions of Python < 2.7, because the testing was relying on specifics of the implementation of
xmlrpclib in Python 2.7. I found some code at this blog post from Forest Bond that showed a better way to test XML-RPC views in Django, namely, by creating a special XML-RPC transport object that uses the Django test client. I extracted this out and tweaked it slightly to add tests and better compatibility across Python versions and published it on PyPI as…
Test Django XML-RPC views using the Django test client. Because you’re using the Django test client, you’re not actually sending HTTP requests and don’t need a server running.
from djangotestxmlrpc import DjangoTestClientXMLRPCTransport class TestXmlRpc(django.test.TestCase): ... def test_list_package(self): pypi = xmlrpclib.ServerProxy( "http://localhost/pypi/", transport=DjangoTestClientXMLRPCTransport(self.client)) pypi_hits = pypi.list_packages() expected = ['foo'] self.assertEqual(pypi_hits, expected)
Supported Python versions
- Python 2.5
- Python 2.6
- Python 2.7
- PyPy 1.9
- Python 3.1
- Python 3.2
or says tox:
~/dev/git-repos/djangotestxmlrpc$ tox ... py25: commands succeeded py26: commands succeeded py27: commands succeeded pypy: commands succeeded py31: commands succeeded py32: commands succeeded congratulations :)
You also can check the latest Travis CI results, but Travis doesn’t build all of the above platforms.
Send your bug reports and feature requests to https://github.com/msabramo/djangotestxmlrpc/issues