def test_indexAnchorsAdded(self): indexer.setIndexFilename('theIndexFile.html') # generate the output file templ = dom.parse(open(d['template'])) tmp = self.makeTemp('lore_index_test.xhtml') tree.doFile(os.path.join(tmp, 'lore_index_test.xhtml'), self.linkrel, '.html', d['baseurl'], templ, d) self.assertXMLEqual( """\ <?xml version="1.0" ?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head><title>Twisted Documentation: The way of the program</title></head> <body bgcolor="white"> <h1 class="title">The way of the program</h1> <div class="content"> <span/> <p>The first paragraph.</p> <h2>The Python programming language<a name="auto0"/></h2> <a name="index01"/> <a name="index02"/> <p>The second paragraph.</p> </div> <a href="theIndexFile.html">Index</a> </body> </html>""", FilePath(tmp).child("lore_index_test.html").getContent())
def test_doFile_withFilenameGenerator(self): base = FilePath(self.mktemp()) base.makedirs() def filenameGenerator(originalFileName, outputExtension): name = os.path.splitext(FilePath(originalFileName).basename())[0] return base.child(name + outputExtension).path templ = dom.parse(open(d['template'])) tree.doFile(self.file, self.linkrel, d['ext'], d['baseurl'], templ, d, filenameGenerator) self.assertXMLEqual( """\ <?xml version="1.0" ?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head><title>Twisted Documentation: My Test Lore Input</title></head> <body bgcolor="white"> <h1 class="title">My Test Lore Input</h1> <div class="content"> <span/> <p>A Body.</p> </div> <a href="index.xhtml">Index</a> </body> </html>""", base.child("simple.xhtml").getContent())
def test_doFile(self): base = FilePath(self.mktemp()) base.makedirs() simple = base.child('simple.html') FilePath(__file__).sibling('simple.html').copyTo(simple) templ = dom.parse(open(d['template'])) tree.doFile(simple.path, self.linkrel, d['ext'], d['baseurl'], templ, d) self.assertXMLEqual( """\ <?xml version="1.0" ?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head><title>Twisted Documentation: My Test Lore Input</title></head> <body bgcolor="white"> <h1 class="title">My Test Lore Input</h1> <div class="content"> <span/> <p>A Body.</p> </div> <a href="index.xhtml">Index</a> </body> </html>""", base.child("simple.xhtml").getContent())
def test_doFile(self): base = FilePath(self.mktemp()) base.makedirs() simple = base.child("simple.html") FilePath(__file__).sibling("simple.html").copyTo(simple) templ = dom.parse(open(d["template"])) tree.doFile(simple.path, self.linkrel, d["ext"], d["baseurl"], templ, d) self.assertXMLEqual( """\ <?xml version="1.0" ?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head><title>Twisted Documentation: My Test Lore Input</title></head> <body bgcolor="white"> <h1 class="title">My Test Lore Input</h1> <div class="content"> <span/> <p>A Body.</p> </div> <a href="index.xhtml">Index</a> </body> </html>""", base.child("simple.xhtml").getContent(), )
def test_indexAnchorsAdded(self): indexer.setIndexFilename('theIndexFile.html') # generate the output file templ = microdom.parse(open(d['template'])) tmp = self.makeTemp('lore_index_test.xhtml') tree.doFile(os.path.join(tmp, 'lore_index_test.xhtml'), self.linkrel, '.html', d['baseurl'], templ, d) self.assertEqualFiles1("lore_index_test_out.html", os.path.join(tmp, "lore_index_test.html"))
def test_doFile_withFilenameGenerator(self): templ = microdom.parse(open(d['template'])) tree.doFile(self.file, self.linkrel, d['ext'], d['baseurl'], templ, d, filenameGenerator) self.assertEqualFiles('good_simple.xhtml', 'simple1.xhtml')