summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-07-15 12:32:14 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-07-15 12:32:14 +0000
commit4537cf3dd40a80f5ad410a62c5a052bf31e68a76 (patch)
treec81cf54b384825b7bf8e6c9b6c65dac51730923c /tests
parentf8a277bc7f67d13fa41eb8569af9fe7446885ed0 (diff)
Fixed the timeuntil and timesince filter tests to not fail if the system 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
Diffstat (limited to 'tests')
-rw-r--r--tests/othertests/templates.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py
index d3b09c5310..3d23d8123b 100644
--- a/tests/othertests/templates.py
+++ b/tests/othertests/templates.py
@@ -1,5 +1,9 @@
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.template import loader
@@ -538,10 +542,10 @@ TEMPLATE_TESTS = {
### TIMESINCE TAG ##################################################
# Default compare with datetime.now()
- 'timesince01' : ('{{ a|timesince }}', {'a':datetime.now() + timedelta(minutes=-1)}, '1 minute'),
- 'timesince02' : ('{{ a|timesince }}', {'a':(datetime.now() - timedelta(days=1))}, '1 day'),
+ 'timesince01' : ('{{ a|timesince }}', {'a':datetime.now() + timedelta(minutes=-1, seconds = -10)}, '1 minute'),
+ 'timesince02' : ('{{ a|timesince }}', {'a':(datetime.now() - timedelta(days=1, minutes = 1))}, '1 day'),
'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
'timesince04' : ('{{ a|timesince:b }}', {'a':NOW + timedelta(days=2), 'b':NOW + timedelta(days=1)}, '1 day'),
@@ -552,9 +556,9 @@ TEMPLATE_TESTS = {
### TIMEUNTIL TAG ##################################################
# Default compare with datetime.now()
- 'timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now() + timedelta(minutes=2)}, '2 minutes'),
- 'timeuntil02' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(days=1))}, '1 day'),
- 'timeuntil03' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(hours=8, minutes=10))}, '8 hours, 10 minutes'),
+ 'timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now() + timedelta(minutes=2, seconds = 10)}, '2 minutes'),
+ 'timeuntil02' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(days=1, seconds = 10))}, '1 day'),
+ 'timeuntil03' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(hours=8, minutes=10, seconds = 10))}, '8 hours, 10 minutes'),
# Compare to a given parameter
'timeuntil04' : ('{{ a|timeuntil:b }}', {'a':NOW - timedelta(days=1), 'b':NOW - timedelta(days=2)}, '1 day'),
@@ -621,5 +625,4 @@ def run_tests(verbosity=0, standalone=False):
raise Exception, msg
if __name__ == "__main__":
- settings.configure()
run_tests(1, True)