Joshua
Joshua

Reputation: 269

Django.contrib.auth Unit tests fail with AUTHENTICATION_BACKENDS enabled

I'm having an issue getting the django.contrib.auth unit tests shipped with Django (1.2.3-3+squeeze1) to pass once an AUTHENTICATION_BACKENDS is set. There are other posts such as Unit testing with remote authentication and How to Unit test with different settings in Django? in regards to fixing, however my tests are still failing with these suggestions.

I've tried adding the following to my SetUP() and TearDown() methods to get around this.

from django.conf import settings
def setUp(self):
    self.old_backend = settings.AUTHENTICATION_BACKENDS
    settings.AUTHENTICATION_BACKENDS = None

def tearDown(self):
    settings.AUTHENTICATION_BACKENDS = self.old_backend

Anyone have any other suggestions for getting around this? Thanks in advance.

Here is a paste of the tracebacks. http://pastebin.com/xX4dmuzr

Upvotes: 1

Views: 400

Answers (2)

Anderson Goulart
Anderson Goulart

Reputation: 11

You can find the bug and a patch here: https://code.djangoproject.com/ticket/13394. I am using 1.3.1 version of django and that patch was not applied yet (don't know why, since it was created a few months ago). I applied manually and it worked!

Upvotes: 1

Joshua
Joshua

Reputation: 269

I was incorrect. Adding this hack to the setUP and tearDown methods to each individual class did work. Going to reach out to the community to find out if this is an actual bug.

Upvotes: 1

Related Questions