Mercurial > genshi > genshi-test
comparison genshi/template/tests/loader.py @ 784:67d324a62cc0 experimental-match-fastpaths
update to 0.5.x branch, up through r907
don't know how this fits in with SoC work, but I wanted to do due diligence and keep this branch working in case it someday gets considered for trunk
author | aflett |
---|---|
date | Mon, 21 Jul 2008 23:17:52 +0000 |
parents | 109fb7dfe95e |
children |
comparison
equal
deleted
inserted
replaced
724:8f2c7023af94 | 784:67d324a62cc0 |
---|---|
258 tmpl1 = loader.load(os.path.join(abspath, 'tmpl1.html')) | 258 tmpl1 = loader.load(os.path.join(abspath, 'tmpl1.html')) |
259 self.assertEqual("""<html> | 259 self.assertEqual("""<html> |
260 <div>Included from searchpath.</div> | 260 <div>Included from searchpath.</div> |
261 </html>""", tmpl1.generate().render()) | 261 </html>""", tmpl1.generate().render()) |
262 assert 'tmpl2.html' in loader._cache | 262 assert 'tmpl2.html' in loader._cache |
263 | |
264 def test_abspath_include_caching_without_search_path(self): | |
265 file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w') | |
266 try: | |
267 file1.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> | |
268 <xi:include href="tmpl2.html" /> | |
269 </html>""") | |
270 finally: | |
271 file1.close() | |
272 | |
273 file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w') | |
274 try: | |
275 file2.write("""<div>Included</div>""") | |
276 finally: | |
277 file2.close() | |
278 | |
279 os.mkdir(os.path.join(self.dirname, 'sub')) | |
280 file3 = open(os.path.join(self.dirname, 'sub', 'tmpl1.html'), 'w') | |
281 try: | |
282 file3.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> | |
283 <xi:include href="tmpl2.html" /> | |
284 </html>""") | |
285 finally: | |
286 file3.close() | |
287 | |
288 file4 = open(os.path.join(self.dirname, 'sub', 'tmpl2.html'), 'w') | |
289 try: | |
290 file4.write("""<div>Included from sub</div>""") | |
291 finally: | |
292 file4.close() | |
293 | |
294 loader = TemplateLoader() | |
295 tmpl1 = loader.load(os.path.join(self.dirname, 'tmpl1.html')) | |
296 self.assertEqual("""<html> | |
297 <div>Included</div> | |
298 </html>""", tmpl1.generate().render()) | |
299 tmpl2 = loader.load(os.path.join(self.dirname, 'sub', 'tmpl1.html')) | |
300 self.assertEqual("""<html> | |
301 <div>Included from sub</div> | |
302 </html>""", tmpl2.generate().render()) | |
303 assert 'tmpl2.html' not in loader._cache | |
263 | 304 |
264 def test_load_with_default_encoding(self): | 305 def test_load_with_default_encoding(self): |
265 f = open(os.path.join(self.dirname, 'tmpl.html'), 'w') | 306 f = open(os.path.join(self.dirname, 'tmpl.html'), 'w') |
266 try: | 307 try: |
267 f.write(u'<div>\xf6</div>'.encode('iso-8859-1')) | 308 f.write(u'<div>\xf6</div>'.encode('iso-8859-1')) |