开发者

Django unit testing failures related to authentication settings

In Django, when I run "manage.py test", I get a lot of authentication related failures. Some examples:

FAIL: test_password_change_succeeds -- AssertionError 200 != 302
FAIL: Logout without next_page option renders the default template -- AssertionError 200 != 302

And:

Failed example:
    form.non_field_errors()
Expected:
    [u'This account is inactive.']
Got:
    [u'Please enter correct username and password....']

I've configured settings.py so that Django will accept authentication from Apache2. In settings, MIDDLEWARE_CLASSES includes 'AuthenticationMiddleware' and 'RemoteUserMiddleware', and AUTHENTICATION_BACKENDS includes 'RemoteUserBacken开发者_开发技巧d'.

How do I figure out the problem here?

UPDATE 2 I cleared the test errors by commenting out the setting of AUTHENTICATION_BACKENDS. Now I have to think about the authentication state I need in my test environment, but at least I've cleared this issue.

The first update had a reference to a question I've since deleted.


If your authentication only works via Apache, I wouldn't expect it to work in tests - the test runner doesn't use Apache. You will need to set up a dummy account in the normal database authentication framework.


As noted above, commenting out the setting of AUTHENTICATION_BACKENDS made the test errors go away.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜