Run initialize() in test setUp() methods.
Review Request #5312 — Created Jan. 23, 2014 and submitted — Latest diff uploaded
Run initialize() in test setUp() methods.
In Django 1.6, the test Client.login() method no longer uses a request, which
means that our middleware that loads the siteconfig isn't guaranteed to run.
For one of our tests, it was hitting the case that the user would be
authenticated against ModelBackend, and then when we tried to do an actual
request, it would load the siteconfig, replacing
settings.AUTHENTICATION_BACKENDS. Once this happened, it would check that
user.backend was in the loaded backends, and when it wasn't, set request.user
to be AnonymousUser.I've solved this issue by calling initialize() inside TestCase.setUp(). A lot
of our TestCase subclasses weren't calling the super class' setUp(), so I've
fixed that.This change isn't required on Django 1.5, but it is backwards compatible. I'm
submitting it now so we can get it in and reduce the size of the Django 1.6
patch.
Ran unit tests.