From 346247a43767d794f5826c2ff82e17715962c98e Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Mon, 14 Jun 2010 06:51:55 -0400 Subject: [PATCH] Allow html entities in html5 --- tests/test_docs.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_docs.py b/tests/test_docs.py index f9a2310..a0198db 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -1,18 +1,29 @@ #!/usr/bin/env python -import unittest, os +import unittest, os, re from xml.dom import minidom from glob import glob +from htmlentitydefs import name2codepoint as n2cp class DocsTest(unittest.TestCase): def test_well_formed(self): + def substitute_entity(match): + ent = match.group(1) + try: + return "&#%d;" % n2cp[ent] + except: + return "&%s;" % ent + for doc in glob('docs/*'): if os.path.isdir(doc): continue if doc.endswith('.css') or doc.endswith('.js'): continue + source = open(doc).read() + source = re.sub('&(\w+);', substitute_entity, source) + try: - minidom.parse(doc) + minidom.parseString(source) except: self.fail('Not well formed: ' + doc); break