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 trialJoseph Poschel
7,525 PointsWhy is my Writer class test not passing?
Just wondering why my Writer model class test is not passing on line 13.
from django.test import TestCase
from .models import Writer
class WriterModelTestCase(TestCase):
'''Tests for the Writer model'''
def writer_email_test(self):
writer = Writer.objects.create(
name="joseph",
email="jposchel@umabju.com",
bio="Hello World"
)
e_address = self.writer.mailto()
self.assertIn("jposchel@umabju.com", e_address)
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsWhile your code is technically correct, the task is specifically look for:
Task 2 of 2: Now add a test that creates an instance of the Writer model and,
using self.assertIn, make sure the
email attribute is in the output of the
mailto() method.
For this to pass, all three aspects need to be on the same line:
self.assertIn(writer.email, writer.mailto())
Joseph Poschel
7,525 PointsJoseph Poschel
7,525 PointsThanks! I tried it but I still an error stating, "Your tests didn't pass."
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsRight! Sorry, the second error was the test name needs to start with test_
writer_email
not end withwriter_email
_test.Joseph Poschel
7,525 PointsJoseph Poschel
7,525 PointsYes, the combination of the line above and
def test_writer_email
worked. Thanks so much!