When my django test case executes, I'm testing my code's ability to
create a new user. But when I use the User.objects.get() method the
user isn't found. The view being tested actually creates users (I
checked it in the browser), but how do I write a test that verifies
it?

Thanks for your help!

from django.contrib.auth.models import User
from django.test import TestCase
from django.test.client import Client

class AccountTest(TestCase):
    def test_create_user(self):
        name = 'Kodos'
        pw = 'password'
        c = Client()
        response = c.post(path='', data={'create_user_name': name,
'create_password': pw})
        self.assertEqual(response.status_code, 200)
        self._assert(User.objects.get(username=name) is not None)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to