~ubuntu-branches/ubuntu/hardy/mako/hardy-backports

« back to all changes in this revision

Viewing changes to test/exceptions_.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2008-09-09 02:09:15 UTC
  • mfrom: (5.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080909020915-y0zgvojsponlnwx8
Tags: 0.2.2-1~hardy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
from mako import exceptions
6
6
from mako.template import Template
 
7
from mako.lookup import TemplateLookup
 
8
from util import result_lines
7
9
 
8
10
class ExceptionsTest(unittest.TestCase):
9
11
    def test_html_error_template(self):
57
59
        else:
58
60
            assert False, ("This function should trigger a CompileException, "
59
61
                           "but didn't")
60
 
            
 
62
    
 
63
    def test_format_exceptions(self):
 
64
        l = TemplateLookup(format_exceptions=True)
 
65
 
 
66
        l.put_string("foo.html", """
 
67
<%inherit file="base.html"/>
 
68
${foobar}
 
69
        """)
 
70
 
 
71
        l.put_string("base.html", """
 
72
        ${self.body()}
 
73
        """)
 
74
 
 
75
        assert '<div class="sourceline">${foobar}</div>' in result_lines(l.get_template("foo.html").render())
 
76
    
 
77
    def test_utf8_format_exceptions(self):
 
78
        """test that htmlentityreplace formatting is applied to exceptions reported with format_exceptions=True"""
 
79
        
 
80
        l = TemplateLookup(format_exceptions=True)
 
81
 
 
82
        l.put_string("foo.html", """# -*- coding: utf-8 -*-
 
83
${u'привет' + foobar}
 
84
""")
 
85
 
 
86
        assert '''<div class="highlight">2 ${u\'&#x43F;&#x440;&#x438;&#x432;&#x435;&#x442;\' + foobar}</div>''' in result_lines(l.get_template("foo.html").render())
 
87
        
61
88
if __name__ == '__main__':
62
89
    unittest.main()