diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/othertests/templates.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py index 6ad97d8f80..963c9ed8e7 100644 --- a/tests/othertests/templates.py +++ b/tests/othertests/templates.py @@ -4,6 +4,7 @@ from django.conf import settings from django import template from django.template import loader from django.utils.translation import activate, deactivate, install +from django.utils.tzinfo import LocalTimezone from datetime import datetime, timedelta import traceback @@ -57,8 +58,9 @@ class OtherClass: def method(self): return "OtherClass.method" -# NOW used by timesince tag tests. +# NOW and NOW_tz are used by timesince tag tests. NOW = datetime.now() +NOW_tz = datetime.now(LocalTimezone(datetime.now())) # SYNTAX -- # 'template_name': ('template contents', 'context dict', 'expected string output' or Exception class) @@ -545,6 +547,9 @@ TEMPLATE_TESTS = { 'timesince04' : ('{{ a|timesince:b }}', {'a':NOW + timedelta(days=2), 'b':NOW + timedelta(days=1)}, '1 day'), 'timesince05' : ('{{ a|timesince:b }}', {'a':NOW + timedelta(days=2), 'b':NOW + timedelta(days=2)}, '0 minutes'), + # Check that timezone is respected + 'timesince06' : ('{{ a|timesince:b }}', {'a':NOW_tz + timedelta(hours=8), 'b':NOW_tz}, '8 hours'), + ### TIMEUNTIL TAG ################################################## # Default compare with datetime.now() 'timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now()}, '0 minutes'), |
