comparison markup/tests/template.py @ 158:8e81177059f3

* Add test case for SVG content embedded in an HTML document. * The XHTML serializer now assumes that elements in a foreign namespace (such as SVG or MathML) can be serialized as empty tags (`<foo />`).
author cmlenz
date Wed, 16 Aug 2006 21:29:48 +0000
parents 1c404be518d1
children 4ed68a904235
comparison
equal deleted inserted replaced
157:40fc3d36f5b4 158:8e81177059f3
645 file1.close() 645 file1.close()
646 646
647 file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w') 647 file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w')
648 try: 648 try:
649 file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> 649 file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude">
650 <xi:include href="tmpl1.html" /> 650 <xi:include href="tmpl1.html" />
651 </html>""") 651 </html>""")
652 finally: 652 finally:
653 file2.close() 653 file2.close()
654 654
655 loader = TemplateLoader([self.dirname]) 655 loader = TemplateLoader([self.dirname])
656 tmpl = loader.load('tmpl2.html') 656 tmpl = loader.load('tmpl2.html')
657 self.assertEqual("""<html> 657 self.assertEqual("""<html>
658 <div>Included</div> 658 <div>Included</div>
659 </html>""", tmpl.generate().render()) 659 </html>""", tmpl.generate().render())
660 660
661 def test_relative_include_subdir(self): 661 def test_relative_include_subdir(self):
662 os.mkdir(os.path.join(self.dirname, 'sub')) 662 os.mkdir(os.path.join(self.dirname, 'sub'))
663 file1 = open(os.path.join(self.dirname, 'sub', 'tmpl1.html'), 'w') 663 file1 = open(os.path.join(self.dirname, 'sub', 'tmpl1.html'), 'w')
664 try: 664 try:
667 file1.close() 667 file1.close()
668 668
669 file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w') 669 file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w')
670 try: 670 try:
671 file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> 671 file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude">
672 <xi:include href="sub/tmpl1.html" /> 672 <xi:include href="sub/tmpl1.html" />
673 </html>""") 673 </html>""")
674 finally: 674 finally:
675 file2.close() 675 file2.close()
676 676
677 loader = TemplateLoader([self.dirname]) 677 loader = TemplateLoader([self.dirname])
678 tmpl = loader.load('tmpl2.html') 678 tmpl = loader.load('tmpl2.html')
679 self.assertEqual("""<html> 679 self.assertEqual("""<html>
680 <div>Included</div> 680 <div>Included</div>
681 </html>""", tmpl.generate().render()) 681 </html>""", tmpl.generate().render())
682 682
683 def test_relative_include_parentdir(self): 683 def test_relative_include_parentdir(self):
684 file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w') 684 file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w')
685 try: 685 try:
686 file1.write("""<div>Included</div>""") 686 file1.write("""<div>Included</div>""")
689 689
690 os.mkdir(os.path.join(self.dirname, 'sub')) 690 os.mkdir(os.path.join(self.dirname, 'sub'))
691 file2 = open(os.path.join(self.dirname, 'sub', 'tmpl2.html'), 'w') 691 file2 = open(os.path.join(self.dirname, 'sub', 'tmpl2.html'), 'w')
692 try: 692 try:
693 file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> 693 file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude">
694 <xi:include href="../tmpl1.html" /> 694 <xi:include href="../tmpl1.html" />
695 </html>""") 695 </html>""")
696 finally: 696 finally:
697 file2.close() 697 file2.close()
698 698
699 loader = TemplateLoader([self.dirname]) 699 loader = TemplateLoader([self.dirname])
700 tmpl = loader.load('sub/tmpl2.html') 700 tmpl = loader.load('sub/tmpl2.html')
701 self.assertEqual("""<html> 701 self.assertEqual("""<html>
702 <div>Included</div> 702 <div>Included</div>
703 </html>""", tmpl.generate().render()) 703 </html>""", tmpl.generate().render())
704 704
705 705
706 def suite(): 706 def suite():
707 suite = unittest.TestSuite() 707 suite = unittest.TestSuite()
708 suite.addTest(doctest.DocTestSuite(Template.__module__)) 708 suite.addTest(doctest.DocTestSuite(Template.__module__))
Copyright (C) 2012-2017 Edgewall Software