mirror of
https://github.com/django/django.git
synced 2025-08-01 17:42:56 +00:00
Fixed #17937 -- Avoided an error in the timeuntil filter when it receives a date object. Thanks Dmitry Guyvoronsky for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4219e2b7f8
commit
1e28567e0d
2 changed files with 12 additions and 8 deletions
|
@ -99,12 +99,18 @@ class TimesinceTests(unittest.TestCase):
|
|||
self.assertEqual(timesince(now_tz), u'0 minutes')
|
||||
self.assertEqual(timeuntil(now_tz, now_tz_i), u'0 minutes')
|
||||
|
||||
def test_date_objects(self):
|
||||
""" Both timesince and timeuntil should work on date objects (#17937). """
|
||||
today = datetime.date.today()
|
||||
self.assertEqual(timesince(today + self.oneday), u'0 minutes')
|
||||
self.assertEqual(timeuntil(today - self.oneday), u'0 minutes')
|
||||
|
||||
def test_both_date_objects(self):
|
||||
""" Timesince should work with both date objects (#9672) """
|
||||
today = datetime.date.today()
|
||||
self.assertEqual(timeuntil(today+self.oneday, today), u'1 day')
|
||||
self.assertEqual(timeuntil(today-self.oneday, today), u'0 minutes')
|
||||
self.assertEqual(timeuntil(today+self.oneweek, today), u'1 week')
|
||||
self.assertEqual(timeuntil(today + self.oneday, today), u'1 day')
|
||||
self.assertEqual(timeuntil(today - self.oneday, today), u'0 minutes')
|
||||
self.assertEqual(timeuntil(today + self.oneweek, today), u'1 week')
|
||||
|
||||
def test_naive_datetime_with_tzinfo_attribute(self):
|
||||
class naive(datetime.tzinfo):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue