Opened 15 years ago
Closed 11 years ago
#13394 closed Bug (wontfix)
django.contrib.auth.tests fail with custom Authentication Backends
Reported by: | Tim Child | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Normal | Keywords: | Auth, contrib, testing |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
When you are using custom Authentication backend the tests in django.contrib.auth.tests.test.FORM_TESTS fail.
FAIL: Doctest: django.contrib.auth.tests.__test__.FORM_TESTS ---------------------------------------------------------------------- Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/test/_doctest.py", line 2180, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for django.contrib.auth.tests.__test__.FORM_TESTS File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/tests/__init__.py", line unknown line number, in FORM_TESTS ---------------------------------------------------------------------- File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/tests/__init__.py", line ?, in django.contrib.auth.tests.__test__.FORM_TESTS Failed example: form.is_valid() Expected: False Got: 403: Forbidden Context: user False
These should obviously not fail, but it would be preferable for a way to override them.
Attachments (2)
Change History (11)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Component: | Testing framework → Contrib apps |
---|---|
milestone: | 1.2 |
Triage Stage: | Unreviewed → Accepted |
This is another example of the wider problem of "integration vs application tests". The test's dependence on an external setting environment means that local application conditions can make the test fail.
Yes, it's annoying, but it's not alone. There are a couple of other places where similar test failures occur. We need address the general problem, but it not critical for 1.2.
comment:3 by , 14 years ago
Component: | Contrib apps → contrib.auth |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
by , 13 years ago
Attachment: | authentication_backend.patch added |
---|
changed some django.contrib tests to explicitly define which middleware classes and authentication backends are assumed to be in settings.
comment:6 by , 13 years ago
Has patch: | set |
---|
I'm resubmitting the (refreshed) patch that I proposed for #17194, with the idea of a DefaultSettingsTestCase to isolate the app tests from any current project settings.
comment:7 by , 11 years ago
Patch needs improvement: | set |
---|
This seems like a good idea to me; patch needs to be updated to apply cleanly though.
#20796 was a recent a duplicate.
comment:8 by , 11 years ago
Isn't this a moot point once 1.6 lands? Django's new unittest discovery mechanism means that auth tests won't be run as part of an end-developer's test suite, so the we don't have to be quite as concerned about adapting to every possible environmental configuration.
comment:9 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Ah, didn't realize that Russ, thanks!
The offending test is:
{{{ # The user submits an invalid username.
... 'username': 'jsmith_does_not_exist',
... 'password': 'test123',
... }
False
[u'Please enter a correct username and password. Note that both fields are case-sensitive.']
}}}