#9868 closed (fixed)
Test client login return values should be improved
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Testing framework | Version: | 1.0 |
Severity: | Keywords: | testing test client login session | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The current implementation of the django.test.client's login method returns either True or False when trying to login a user, however, there is no way of knowing why a login failed.
The login method could probably be modified to raise an exception with further information regarding why the login failed. For example, if INSTALLED_APPS does not include 'settings'.
Change History (4)
comment:1 by , 16 years ago
Component: | Uncategorized → Testing framework |
---|
comment:2 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:3 by , 16 years ago
Resolution: | wontfix → fixed |
---|
(In [9979]) Improved table join handling for comparisons against NULL.
This fixes a broad class of bugs involving filters that look for missing
related models and fields. Most of them don't seem to have been reported
(the added tests cover the root cause). The exception is that this has
also fixed #9868.
comment:4 by , 16 years ago
Ignore previous comment. I typo'd the bug number (should have been #9968).
I think that changing login() to raise an exception instead of returning False would be a backwards incompatibility. Testing to see if a login worked, and then if it returns false doing something else is probably used in people's test suites.
I agree that it would be nice to know why a login might fail, but I don't know if we can change this behavior without breaking pre-existing test suites.
I'm marking this wontfix, but if you can produce a patch and tests that show that this doesn't break Django's test suite, please re-open.
I changed the return False to a raise Exception, and 2 of Django's test client tests did indeed fail.