From 0f4310ae128a0566d863d47a677b6a0b35d8dc18 Mon Sep 17 00:00:00 2001 From: "R. Tyler Ballance" Date: Wed, 16 Dec 2009 19:03:00 -0800 Subject: Refactor the InlineSpanishTest to better clarify a success/failure scenario --- cheetah/Tests/Unicode.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cheetah/Tests/Unicode.py b/cheetah/Tests/Unicode.py index c8b3955..c881d86 100644 --- a/cheetah/Tests/Unicode.py +++ b/cheetah/Tests/Unicode.py @@ -195,9 +195,9 @@ class Unicode_in_SearchList_Test(CommandLineTest): class InlineSpanishTest(unittest.TestCase): - def runTest(self): - template = ''' -#encoding utf-8 + def setUp(self): + super(InlineSpanishTest, self).setUp() + self.template = ''' @@ -216,11 +216,22 @@ class InlineSpanishTest(unittest.TestCase): ''' + + def test_failure(self): + """ Test a template lacking a proper #encoding tag """ + self.failUnlessRaises(UnicodeDecodeError, Template, self.template, searchList=[{'header' : '', + 'nombre' : '', 'numpedidos_bodega' : '', + 'numpedidos_noconf' : ''}]) + + def test_success(self): + """ Test a template with a proper #encoding tag """ + template = '#encoding utf-8\n%s' % self.template template = Template(template, searchList=[{'header' : '', 'nombre' : '', 'numpedidos_bodega' : '', 'numpedidos_noconf' : ''}]) - assert unicode(template) - + self.assertTrue(unicode(template)) + + if __name__ == '__main__': unittest.main() -- cgit v1.2.1