Advertisement
urbanslug

asserEqual fail

Jul 19th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.83 KB | None | 0 0
  1. user@comp:~/code/python/django/mysite$ python manage.py test polls
  2. Creating test database for alias 'default'...
  3.  
  4. ----------------------------------------------------------------------
  5. Ran 0 tests in 0.000s
  6.  
  7. OK
  8. Destroying test database for alias 'default'...
  9.  
  10.  
  11. ======================================================================================================
  12. tests.py
  13. ======================================================================================================
  14. from django.test import TestCase
  15. from django.utils import timezone
  16.  
  17. import datetime
  18. from polls.models import Poll
  19. # Create your tests here.
  20.  
  21. class PollMethodTests(TestCase):
  22.     def was_published_recently_with_future_poll(self):
  23.              """
  24.              was_published_recently() should return False for polls whose
  25.              pub_date is in the future
  26.              """
  27.          #future_poll = Poll(pub_date=timezone.now() + datetime.timedelta(days=30))
  28.          self.assertEqual(True, False)
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. =======================================================================================================
  37. models.py being tested
  38. =======================================================================================================
  39.  
  40.  
  41.  
  42.  
  43. from django.db import models
  44. import datetime
  45. from django.utils import timezone
  46.  
  47.  
  48. # Create your models here.
  49.  
  50. class Poll(models.Model):
  51.     question = models.CharField(max_length=200)
  52.     pub_date = models.DateTimeField('date published')
  53.  
  54.     def __unicode__(self):
  55.         return self.question
  56.  
  57.     def was_published_recently(self):
  58.         now = timezone.now()
  59.         return now - datetime.timedelta(days=1) <= self.pub_date < now
  60.  
  61. class Choice(models.Model):
  62.     poll        = models.ForeignKey(Poll)
  63.     choice_text = models.CharField(max_length=200)
  64.     votes       = models.IntegerField(default=0)
  65.  
  66.     def __unicode__(self):
  67.         return self.choice_text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement