Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Test Time Test our article detail template

Arran Cardnell
Arran Cardnell
12,313 Points

Django-basics/test-time/test-our-article-detail-template - "Bummer! Try again!"

My code keeps giving me the error "Bummer! Try again!". Is this a testing gremlin again or is there something I'm missing in my code? It looks right to me:

import datetime

from django.core.urlresolvers import reverse
from django.test import TestCase

from .models import Article, Writer

class ArticleDetailViewTestCase(TestCase):
    '''Tests for the Article detail view'''

    def setUp(self):
        self.writer = Writer.objects.create(
            name='Kenneth Love',
            email='kenneth@teamtreehouse.com',
            bio='Your friendly, local Python teacher'
        )
        self.article = Article.objects.create(
          writer=self.writer,
          headline='Article 0',
          content='Something about 0',
          publish_date=datetime.datetime.today()
        )

    def test_detail_template(self):
        '''Make sure the `articles/article_detail.html` template is used'''
        resp = self.client.get(reverse('articles:detail', kwargs={'pk': self.article.pk}))
        self.assertTemplateUsed(resp, 'articles/article_detail.html')

    def test_detail_template_writer(self):
        '''Make sure the article writer's name is in the rendered output'''

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

Sadly, it is a testing gremlin :japanese_goblin: again. Your code is correct as written.

I've been tagging Kenneth Love on each gremlin sighting for tracking.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

Good news! Your code is now passing the test-our-article-detail-template challenge!