Beispiel #1
0
    def test_named_article_with_image(self):
        with open(os.path.join(self.tmp_dir, '1998/bike.html'), 'wt') as stream:
            stream.write("""<html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <title>Colour graphics the hard way - Alleged Literature</title>
                <link href="../pdc.css" rel="alternate stylesheet" type="text/css" title="Spirals" />
                </head>
                <body>
                <div id="body">
                  <h1>My recently deceased bike</h1>
                  <p class="initial">
                    <a href="19980529g.jpg"><img src="19980529g-stamp.jpg" align="right"
                        alt="[Link to bike photo&mdash;22K JPEG]" width="86" height="64" border="0" /></a>

                    This is my new bike (at least, new in Summer 1998).
                  </p>
                </div>
                </body>
                </html>""")
        article = get_named_article(self.tmp_dir, '/blog/', '/im/', 1998, 'bike')
        expected = """<p class="initial">
            <a href="/im/1998/19980529g.jpg"><img src="/im/1998/19980529g-stamp.jpg"
                align="right" alt="[Link to bike photo\u201422K JPEG]" width="86" height="64" border="0" /></a>

            This is my new bike (at least, new in Summer 1998).
          </p>"""
        actual = article.body
        self.assertHTMLEqual(expected, actual)
Beispiel #2
0
 def test_named_article(self):
     with open(os.path.join(self.tmp_dir, '2003/ancient.html'), 'wt') as stream:
         stream.write("""<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
         'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
         <html xmlns="http://www.w3.org/1999/xhtml">
           <!-- Generated from graphics-the-hard-way.th on 2006-10-29 09:49 GMT -->
           <head>
             <title>Colour graphics the hard way - Alleged Literature</title>
             <link href="../pdc.css" rel="alternate stylesheet" type="text/css" title="Spirals" />
           </head>
           <body>
             <p class="trail">
               <a href="./">2002</a> &gt;&gt;
               <strong>graphics-the-hard-way</strong>
             </p>
             <div id="body">
               <h1>Colour graphics the hard way</h1>
               <p>
               On my badly broken Linux desktop,
               the Gimp is missing its file-saving plug-ins, so it cannot save
               files except in a format I&nbsp;cannot use.
               </p>
               <p><a href="11.html#e20021125a">25 November 2002</a></p>
             </div>
             <div class="links">
               <h3>Archives</h3>
               <ul>
                 <li><a href="../2006/topics.html">by topic</a></li>
                 <li><a href="../2006/">2006</a></li>
                 <li><a href="../2005/">2005</a></li>
               </ul>
             </div>
             <div class="links">
               <p><a title="Link to an XML summary in RSS 2.0 format"
                 href="../rss091.xml" type="text/xml"><img src="../../img/xml.gif"
                 alt="XML" width="36" height="14" border="0" /></a></p>
             </div>
           </body>
         </html>""")
     article = get_named_article(self.tmp_dir, '/blog/', '/im/', 2003, 'ancient')
     self.assertEqual('Colour graphics the hard way', article.title)
     self.assertEqual('/blog/2003/ancient.html', article.href)
     self.assertHTMLEqual("""<p>
         On my badly broken Linux desktop,
         the Gimp is missing its file-saving plug-ins, so it cannot save
         files except in a format I\u00A0cannot use.
         </p>
         <p><a href="/blog/2003/11.html#e20021125a">25 November 2002</a></p>""", article.body)