Edgewall Software

Changeset 1193 for trunk


Ignore:
Timestamp:
Dec 29, 2012, 9:18:24 PM (11 years ago)
Author:
hodgestar
Message:

Add a test that demonstrates that absolute includes work (see #465).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/genshi/template/tests/loader.py

    r1160 r1193  
    272272        self.assertEqual("""<html>
    273273              <div>Included from sub</div>
     274            </html>""", tmpl.generate().render(encoding=None))
     275
     276    def test_absolute_include(self):
     277        file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w')
     278        try:
     279            file1.write("""<div>Included</div>""")
     280        finally:
     281            file1.close()
     282
     283        os.mkdir(os.path.join(self.dirname, 'sub'))
     284        file2 = open(os.path.join(self.dirname, 'sub', 'tmpl2.html'), 'w')
     285        try:
     286            file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude">
     287              <xi:include href="%s/tmpl1.html" />
     288            </html>""" % self.dirname)
     289        finally:
     290            file2.close()
     291
     292        loader = TemplateLoader()
     293        tmpl = loader.load(os.path.abspath(os.path.join(self.dirname, 'sub',
     294                                                        'tmpl2.html')))
     295        self.assertEqual("""<html>
     296              <div>Included</div>
    274297            </html>""", tmpl.generate().render(encoding=None))
    275298
Note: See TracChangeset for help on using the changeset viewer.