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 list view

Arran Cardnell
Arran Cardnell
12,313 Points

Django basics/Test Time/Test our article list view - refuses to pass

I've been trying to get past this challenge for a while now, but the only response I get back is "Bummer! Try again!". I can't see what is wrong with my code and I feel like I'm going round in circles. What am I missing??

Arran Cardnell
Arran Cardnell
12,313 Points
import datetime

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

from .models import Article, Writer

class ArticleListViewTestCase(TestCase):
    '''Tests for the Article list 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()
        )
        for x in range(1, 3):
            Article.objects.create(
                writer=self.writer,
                headline='Article {}'.format(x),
                content='Something about {}'.format(x),
                publish_date=datetime.datetime.today()
            )

    def test_article_list_view(self):
        resp = self.client.get(reverse("articles:list"))
        self.assertIn(self.article, resp.context['articles'])

[MOD: added ```python markdown formatting -cf]

4 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

Your code matches my solution, which now appears to fail.... In recent days, the checker for some challenges have become flaky reporting false fails. The best you can do is try it again later.

Tagging Kenneth Love to notice another grader imp in the works :imp:

Arran Cardnell
Arran Cardnell
12,313 Points

That's frustrating if that's true. I've spent over an hour trying to solve this....

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

Happy News! The gremlins have left the grader. Your code now passes as is!

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Yeah, looks like a test gremlin. I'll keep an eye out for others. Django's testing setup and our CC runner aren't the best of friends, sadly.

Arran Cardnell
Arran Cardnell
12,313 Points

Just wanted to confirm that this is now working! Thanks for dealing with the gremlin. Maybe gremlins are to blame for all my code failures.....

I feel like this is occurring again. Any insight?

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

The code from the other answer passes the challenge. (Tested 17:58 1/19/2016)