def test_unicode(self): html = u'<div>ÅÄÖ</div>' output = fix_html(html) output = output.decode("utf-8") self.assertEqual(output, u'<div>ÅÄÖ</div>', "Got:" + output)
def test_no_modify_anchor(self): """An <a> tag before an <img> is not modified.""" html = '<a name="anchor"></a><img src="http://www.foobar.com" alt="bar">' output = fix_html(html) self.assertIn('<a name="anchor"></a>', output, "Got:" + output)
def test_no_modify_existing_alt_caps(self): html = '<img src="http://www.foobar.com" ALT="bar">' output = fix_html(html) self.assertEqual(output, '<img src="http://www.foobar.com" alt="bar">', "Got:" + output)
def test_no_modify_existing_alt(self): """ Check that existing ALT attribute stays untouched """ html = '<img src="http://www.foobar.com" alt="bar">' output = fix_html(html) self.assertEqual(output, '<img src="http://www.foobar.com" alt="bar">', "Got:" + output)
def test_add_alt_tag(self): """ Check that images receive empty alt tag if one is missing """ html = '<img src="http://www.foobar.com">' output = fix_html(html) self.assertEqual(output, '<img src="http://www.foobar.com" alt="">', "Got:" + output)