djangotestxmlrpc

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…

djangotestxmlrpc

Build Status

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.

Example usage:

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.

Issues

Send your bug reports and feature requests to https://github.com/msabramo/djangotestxmlrpc/issues

More pull requests accepted into South

I had a few more of my contributions accepted into South:

Bitbucket pull request #10: Make `schemamigration` output more readable and PEP8-compliant
Bitbucket pull request #11: Print the failing SQL when a query fails
Bitbucket pull request #12: For manage.py migrate –list –verbosity=2, print the datetime that migrations were applied
Bitbucket pull request #13: Add ability to migrate forwards and backwards easily one by one

print_settings: A super simple and useful custom Django management command

A large number of problems that we have with our Django project at work turn out to be because of settings that are not what they should be (note that our settings are not straightforward to see with a glance at settings.py since we use multiple settings files for production, dev, and common settings). I thought that it might be useful to have a Django management command that shows the settings in effect after all the settings files are processed.

It was super easy to write and is a tiny amount of code, but I have a feeling that this will quickly curtail a lot of problems.

Sample invocation: