Permalink
Browse files

Refactor the InlineSpanishTest to better clarify a success/failure sc…

…enario
  • Loading branch information...
1 parent 752cb3a commit 0f4310ae128a0566d863d47a677b6a0b35d8dc18 @rtyler rtyler committed Dec 17, 2009
Showing with 16 additions and 5 deletions.
  1. +16 −5 cheetah/Tests/Unicode.py
View
@@ -195,9 +195,9 @@ def test_Thai_utf8(self):
class InlineSpanishTest(unittest.TestCase):
- def runTest(self):
- template = '''
-#encoding utf-8
+ def setUp(self):
+ super(InlineSpanishTest, self).setUp()
+ self.template = '''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@@ -216,11 +216,22 @@ def runTest(self):
</body>
</html>
'''
+
+ 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()

0 comments on commit 0f4310a

Please sign in to comment.