You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code example to add tests, I would also suggest that you clearify the code example. It should be made clear that the test file already has existing code that the test and import should be appended with:
from django.contrib.auth import get_user_model
.
.
.
.
class HomePageTests(TestCase):
"""Test whether our blog entries show up on the homepage"""
def setUp(self):
self.user = get_user_model().objects.create(username='some_user')
def test_one_entry(self):
Entry.objects.create(title='1-title', body='1-body', author=self.user)
response = self.client.get('/')
self.assertContains(response, '1-title')
self.assertContains(response, '1-body')
def test_two_entries(self):
Entry.objects.create(title='1-title', body='1-body', author=self.user)
Entry.objects.create(title='2-title', body='2-body', author=self.user)
response = self.client.get('/')
self.assertContains(response, '1-title')
self.assertContains(response, '1-body')
self.assertContains(response, '2-title')
Activity
michaelerobertsjr commentedon Oct 18, 2014
In the code example to add tests, I would also suggest that you clearify the code example. It should be made clear that the test file already has existing code that the test and import should be appended with:
from django.contrib.auth import get_user_model
.
.
.
.
class HomePageTests(TestCase):