示例#1
0
 def test_unicode_to_unicode(self):
     entry = module.Entry(dict(text=u'szőlőfeldolgozó üzem'),
                          Template('{{text}}'))
     self.assertEqual(entry.render(), u'szőlőfeldolgozó üzem')
示例#2
0
 def test_document_renders_entries(self):
     entry = module.Entry({}, Template('An entry.'))
     document = module.Document(
         [entry] * 3,
         Template('{% for entry in entries %}{{entry}}{% endfor %}'))
     self.assertEqual(str(document), 'An entry.An entry.An entry.')
示例#3
0
 def callable():
     entry = module.Entry(dict(a='1, 2, 3', render=4), Template(''))
示例#4
0
 def callable():
     entry = module.Entry(dict(a='1, 2, 3', apply_all_filters=4),
                          Template(''))
示例#5
0
 def test_field_can_be_reached_directly(self):
     entry = module.Entry(dict(a='1, 2, 3', b=4), Template(''))
     self.assertEqual(entry.b, '4')
示例#6
0
 def callable():
     entry = module.Entry(dict(a='1, 2, 3', b=4), Template(''))
     print entry.c
示例#7
0
 def test_filters_applied_before_rendering(self):
     entry = module.Entry(dict(a='123', b=4), Template('{{a}}'),
                          dict(a=['append:4']))
     self.assertEqual(entry.render(), '1234')
示例#8
0
 def test_filters_not_applied_twice(self):
     entry = module.Entry(dict(a='123', b=4), Template(''),
                          dict(a=['append:4']))
     entry.apply_all_filters()
     entry.apply_all_filters()
     self.assertEqual(entry.fields['a'], '1234')
示例#9
0
 def callable():
     entry = module.Entry(dict(a=1), Template(''), dict(b=['split']))
示例#10
0
 def test_filters_are_optional(self):
     entry = module.Entry(dict(a='1, 2, 3', b=4), Template(''))
     entry.apply_all_filters()
     self.assertEqual(entry.fields['a'], '1, 2, 3')
示例#11
0
 def test_filter_does_not_change_other_field(self):
     entry = module.Entry(dict(a='1, 2, 3', b=4), Template(''),
                          dict(a=['split']))
     entry.apply_all_filters()
     self.assertEqual(entry.fields['b'], 4)
示例#12
0
 def test_filter_knownvalues(self):
     entry = module.Entry(dict(a='1, 2, 3', b=4), Template(''),
                          dict(a=['split']))
     entry.apply_all_filters()
     self.assertListEqual(entry.fields['a'], ['1', '2', '3'])
示例#13
0
 def test_known_examples(self):
     entry = module.Entry(dict(x=1), Template('Value is {{x}}'))
     self.assertEqual(str(entry), 'Value is 1')
示例#14
0
 def test_entry_as_string(self):
     entry = module.Entry({}, Template('Dummy template'))
     self.assertEqual(str(entry), 'Dummy template')
示例#15
0
 def test_entry_accepts_none(self):
     entry = module.Entry({})