def xx():
冒号下一行要缩进
ATD
http://blog.csdn.net/doupei2006/article/details/7657547
http://www.jb51.net/article/64633.htm
>>> import datetime
>>> from django.utils import timezone
>>> from polls.models import Question
>>> # create a Question instance with pub_date 30 days in the future
>>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30))
>>> # was it published recently?
>>> future_question.was_published_recently()
True
tests.py
class QuestionMethodTest(TestCase): def test_was_published_recently_with_future_question(self):
#was_published_recently()should return False for questions whose
#pub_date is in the future
time=timezone.now()+datetime.timedelta(days=30)
future_question=Question(pub_date=time)
self.assertEqual(future_question.was_published_recently(),False)
if def for :::