Ticket #10318: tests.py

File tests.py, 614 bytes (added by Sean Brant, 16 years ago)

Test case

Line 
1from django.test import TestCase
2
3class SimpleTest(TestCase):
4 def test_template_timestamp(self):
5 from datetime import datetime
6 from django.template import Context, Template
7 now = datetime.now()
8 t = Template('{{ now|date:"U" }}')
9 c = Context({'now': now})
10 self.failUnlessEqual(int(now.strftime('%s')), int(t.render(c)))
11
12 def test_template_rawdate(self):
13 from datetime import datetime
14 from django.template import Context, Template
15 now = datetime.now()
16 t = Template('{{ now|date:"Y-m-d H:i:s" }}')
17 c = Context({'now': now})
18 self.failUnlessEqual(now.strftime('%F %T') ,t.render(c))
19
20
21
Back to Top