Closed hltbra closed 14 years ago
import unittest from livefeed.models import FeedItem from ludibrio import Stub from datetime import datetime
NOW = datetime(year=2010, month=12, day=20, hour=10, minute=15, second=30) UM_DIA_ATRAS = datetime(year=self.now.year, month=self.now.month, day=self.now.day-1)
class LiveFeedItemTestCase(unittest.TestCase): def setUp(self): self.template = 'myapp/templates/template1.html'
def test_um_dia_atras(self):
with Stub() as datetime:
from datetime import datetime
datetime.now() >> NOW
item = FeedItem(template=self.template, date=UM_DIA_ATRAS)
self.assertEquals('há 1 dia', item.tempo())
code::
If we remove that from .. import to outside those methods, it does not work!