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
My test fails since both objects are created at the same time
My 'now' and 'course.created_at' have the same time up to millisecond. I noticed that my test was run in 0.001s while the one on video took 0.003s. So is it possible that my test run so fast that both objects have the same time?
Kenneth LoveTreehouse Guest Teacher
Unlikely but, sure, it could conceivably happen. You could import the
time module and then do
time.sleep(2) between the two object creations. That'll insert 2 milliseconds of wait time.
Thanks! It solved the problem
Team GDizCourses Plus Student 24,942 Points
I ran into the same problem. time.sleep(2) fixed it for me too :).
As far as the issue happens cause of system speed (SSD, fast enough processor, unloaded system, etc) - two actions are being processed at the very same mili-second. I've resolved it by creating a loop-function, making a thousand of divisions of floats. Which creates timestub needed for the system to differentiate the actions.
[0.9 / (counter + 1) for counter in range(1000)]