Skip to content

Commit

Permalink
Fixed the timeuntil and timesince filter tests to not fail if the sys…
Browse files Browse the repository at this point in the history
…tem clock

ticks over during the tests. Also fixed the template tests to be able to run in
standalone mode again.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3354 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Jul 15, 2006
1 parent f8a277b commit 4537cf3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/othertests/templates.py
@@ -1,5 +1,9 @@
from django.conf import settings from django.conf import settings


if __name__ == '__main__':
# When running this file in isolation, we need to set up the configuration
# before importing 'template'.
settings.configure()


from django import template from django import template
from django.template import loader from django.template import loader
Expand Down Expand Up @@ -538,10 +542,10 @@ def method(self):


### TIMESINCE TAG ################################################## ### TIMESINCE TAG ##################################################
# Default compare with datetime.now() # Default compare with datetime.now()
'timesince01' : ('{{ a|timesince }}', {'a':datetime.now() + timedelta(minutes=-1)}, '1 minute'), 'timesince01' : ('{{ a|timesince }}', {'a':datetime.now() + timedelta(minutes=-1, seconds = -10)}, '1 minute'),
'timesince02' : ('{{ a|timesince }}', {'a':(datetime.now() - timedelta(days=1))}, '1 day'), 'timesince02' : ('{{ a|timesince }}', {'a':(datetime.now() - timedelta(days=1, minutes = 1))}, '1 day'),
'timesince03' : ('{{ a|timesince }}', {'a':(datetime.now() - 'timesince03' : ('{{ a|timesince }}', {'a':(datetime.now() -
timedelta(hours=1, minutes=25))}, '1 hour, 25 minutes'), timedelta(hours=1, minutes=25, seconds = 10))}, '1 hour, 25 minutes'),


# Compare to a given parameter # Compare to a given parameter
'timesince04' : ('{{ a|timesince:b }}', {'a':NOW + timedelta(days=2), 'b':NOW + timedelta(days=1)}, '1 day'), 'timesince04' : ('{{ a|timesince:b }}', {'a':NOW + timedelta(days=2), 'b':NOW + timedelta(days=1)}, '1 day'),
Expand All @@ -552,9 +556,9 @@ def method(self):


### TIMEUNTIL TAG ################################################## ### TIMEUNTIL TAG ##################################################
# Default compare with datetime.now() # Default compare with datetime.now()
'timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now() + timedelta(minutes=2)}, '2 minutes'), 'timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now() + timedelta(minutes=2, seconds = 10)}, '2 minutes'),
'timeuntil02' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(days=1))}, '1 day'), 'timeuntil02' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(days=1, seconds = 10))}, '1 day'),
'timeuntil03' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(hours=8, minutes=10))}, '8 hours, 10 minutes'), 'timeuntil03' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(hours=8, minutes=10, seconds = 10))}, '8 hours, 10 minutes'),


# Compare to a given parameter # Compare to a given parameter
'timeuntil04' : ('{{ a|timeuntil:b }}', {'a':NOW - timedelta(days=1), 'b':NOW - timedelta(days=2)}, '1 day'), 'timeuntil04' : ('{{ a|timeuntil:b }}', {'a':NOW - timedelta(days=1), 'b':NOW - timedelta(days=2)}, '1 day'),
Expand Down Expand Up @@ -621,5 +625,4 @@ def run_tests(verbosity=0, standalone=False):
raise Exception, msg raise Exception, msg


if __name__ == "__main__": if __name__ == "__main__":
settings.configure()
run_tests(1, True) run_tests(1, True)

0 comments on commit 4537cf3

Please sign in to comment.