Thanks! I see what I did wrong now.
class UserProfileTest(TestCase):
# Create User
def setUp(self):
self.user = User.objects.create_user(username='captain', password='america')
# Logged in
def test_VIEW_USER__Logged_in(self):
self.assertTrue(isinstance(self.user, User))
login = self.client.login(username='captain', password='america')
self.assertEqual(login, True)
https://docs.djangoproject.com/en/1.5/intro/tutorial05/#testing-our-new-view
class UserProfileTest(TestCase):
# User factory method
def create_user(self, username='joe', password='joe'):
return User.objects.create(username=username, password=password)
# Create User
def test_creation_USER(self):
u = self.create_user()
self.assertTrue(isinstance(u, User))
login = self.client.login(username='joe', password='joe')
On Thursday, July 3, 2014 2:57:24 PM UTC+2, Amim Knabben wrote:
-- class UserProfileTest(TestCase):
# Create User
def setUp(self):
self.user = User.objects.create_user(username='captain', password='america')
# Logged in
def test_VIEW_USER__Logged_in(self):
self.assertTrue(isinstance(self.user, User))
login = self.client.login(username='captain', password='america')
self.assertEqual(login, True)
https://docs.djangoproject.com/en/1.5/intro/tutorial05/#testing-our-new-view
class UserProfileTest(TestCase):
# User factory method
def create_user(self, username='joe', password='joe'):
return User.objects.create(username=username, password=password)
def test_creation_USER(self):
u = self.create_user()
self.assertTrue(isinstance(u, User))
login = self.client.login(username='joe', password='joe')
self.assertEqual(login, True)
On Thursday, July 3, 2014 2:57:24 PM UTC+2, Amim Knabben wrote:
duplicated questionOn Thu, Jul 3, 2014 at 9:09 AM, Pepsodent Cola <pepsod...@gmail.com> wrote:I want to run a unit test for a user logging in but I get error. What am I doing wrong?--
from django.test import TestCase
from userprofile.models import UserProfile
from django.contrib.auth.models import User
class UserProfileTest(TestCase):
# User factory method
def create_user(self, username='joe', password='joe'):
return User.objects.create(username=username, password=password)
# Create User
def test_creation_USER(self):
u = self.create_user()
self.assertTrue(isinstance(u, User))
login = self.client.login(username='joe', password='joe')
self.assertEqual(login, True)
============================================================ ==========
FAIL: test_creation_USER (userprofile.tests.UserProfileTest)
------------------------------------------------------------ ----------
Traceback (most recent call last):
File "/home/Django/project/userprofile/tests.py", line 44, in test_creation_USER
self.assertEqual(login, True)
AssertionError: False != True
------------------------------------------------------------ ----------
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5d49c776- .fe1f-4702-abc1-d2c99468d82a% 40googlegroups.com
For more options, visit https://groups.google.com/d/optout .
--AMIM KNABBEN+55 48 9680 9126 (m)
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9974fc0b-a1ec-4048-9a24-3773b9f3540d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment