Problem solved. I forgot that .create_user will create and return a hashed
password, which obviously won't work if said returned object password
property is entered into the password field of the login form.
On Wednesday, March 28, 2012 12:05:49 AM UTC-6, jondbaker wrote:
>
> I'm trying to write a unit test that will verify that the login form
> authenticates a user. Whenever I run 'manage.py test' the runner fails with
> this message:
> *AssertionError: False is not True*
>
> *tests.py*
> from django.test import TestCase
> from django.test.client import Client
> from django.contrib.auth.models import User
>
> class TestAccountLogin(TestCase):
> def setUp(self):
> self.client = Client()
>
> def test_login(self):
> user = User.objects.create_user('test', '[email protected]',
> 't3stp@s$')
> response = self.client.login(username=user.username,
> password=user.password)
> self.assertTrue(response)
>
> After creating the user, I can verify that user.is_active is in fact True,
> but unfortunately response returns False. Both
> 'django.contrib.auth.middleware.AuthenticationMiddleware' and
> 'django.contrib.auth' are declared in settings.py.
>
> Any thoughts?
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/6PqfFCkJUz0J.
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-users?hl=en.