#9868: Test client login return values should be improved
------------------------------------------------------+---------------------
Reporter: David Sauve <[email protected]> | Owner: nobody
Status: closed | Milestone:
Component: Testing framework | Version: 1.0
Resolution: wontfix | Keywords: testing
test client login session
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
------------------------------------------------------+---------------------
Changes (by ericholscher):
* status: new => closed
* resolution: => wontfix
Comment:
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.
{{{
======================================================================
ERROR: Request a page that is protected with @login, but use bad
credentials
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ericholscher/Python/django-
trunk/tests/modeltests/test_client/models.py", line 303, in
test_view_with_bad_login
login = self.client.login(username='otheruser', password='nopassword')
File "/Users/ericholscher/Python/django-trunk/django/test/client.py",
line 408, in login
raise Exception
Exception
======================================================================
ERROR: Request a page that is protected with @login, but use an inactive
login
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ericholscher/Python/django-
trunk/tests/modeltests/test_client/models.py", line 309, in
test_view_with_inactive_login
login = self.client.login(username='inactive', password='password')
File "/Users/ericholscher/Python/django-trunk/django/test/client.py",
line 408, in login
raise Exception
Exception
----------------------------------------------------------------------
Ran 34 tests in 0.933s
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/9868#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---