comparison genshi/template/tests/loader.py @ 935:705727288d7e

Merge r1143 from py3k: add support for python 3 to remaining genshi.template components: * minor changes to track encoding=None API change in core genshi modules. * genshi/template/directives: * slightly odd syntax changes to make the 2to3 .next() fixer pick up *stream.next() * minor test fix for change in behaviour of division (/) in Python 3. * genshi/template/loader: * add 'b' to file modes to ensure it's loaded as bytes in Python 3. * use not isinstance(s, unicode) instead of isinstance(s, str) since the former is correctly converted by 2to3.
author hodgestar
date Fri, 18 Mar 2011 09:17:52 +0000
parents 85e4678337cf
children
comparison
equal deleted inserted replaced
934:7c9ec79caedc 935:705727288d7e
345 <div>Included from sub</div> 345 <div>Included from sub</div>
346 </html>""", tmpl2.generate().render(encoding=None)) 346 </html>""", tmpl2.generate().render(encoding=None))
347 assert 'tmpl2.html' not in loader._cache 347 assert 'tmpl2.html' not in loader._cache
348 348
349 def test_load_with_default_encoding(self): 349 def test_load_with_default_encoding(self):
350 f = open(os.path.join(self.dirname, 'tmpl.html'), 'w') 350 f = open(os.path.join(self.dirname, 'tmpl.html'), 'wb')
351 try: 351 try:
352 f.write(u'<div>\xf6</div>'.encode('iso-8859-1')) 352 f.write(u'<div>\xf6</div>'.encode('iso-8859-1'))
353 finally: 353 finally:
354 f.close() 354 f.close()
355 loader = TemplateLoader([self.dirname], default_encoding='iso-8859-1') 355 loader = TemplateLoader([self.dirname], default_encoding='iso-8859-1')
356 loader.load('tmpl.html') 356 loader.load('tmpl.html')
357 357
358 def test_load_with_explicit_encoding(self): 358 def test_load_with_explicit_encoding(self):
359 f = open(os.path.join(self.dirname, 'tmpl.html'), 'w') 359 f = open(os.path.join(self.dirname, 'tmpl.html'), 'wb')
360 try: 360 try:
361 f.write(u'<div>\xf6</div>'.encode('iso-8859-1')) 361 f.write(u'<div>\xf6</div>'.encode('iso-8859-1'))
362 finally: 362 finally:
363 f.close() 363 f.close()
364 loader = TemplateLoader([self.dirname], default_encoding='utf-8') 364 loader = TemplateLoader([self.dirname], default_encoding='utf-8')
Copyright (C) 2012-2017 Edgewall Software