Django~automated tests

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 :::

三年有成,问苍茫~
原文地址:https://www.cnblogs.com/lynclynn/p/5217927.html