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!
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
Oleksiy Ovdienko447 Points
Is it good if test in this video doesn't passes, crashes with error on self.assertLess course.created_at not less than
Is it good if test in this video doesn't passes, crashes with error on self.assertLess course.created_at not less than now ?
No... if you followed the videos up until now and added the code as Kenneth did, that test should pass without an issue.
If you're worried that the times you're comparing are too close together, you could add a delay by using time.sleep():
from django.test import TestCase from django.utils import timezone import time # don't forget to import the module first from .models import Course class CourseModelTests(TestCase): def test_course_creation(self): course = Course.objects.create( title="Python Regular Expressions", description="Learn to write regular expressions in Python" ) time.sleep(1) # sleep/delay for one second now = timezone.now() self.assertLess(course.created_at, now)
Jeff MudayTreehouse Moderator 28,372 Points
Some test environments on your local host will be so fast that when you run now it will be in the same millisecond as the creation step. This happens on my home computer.
Your test is fine.