File: test_docs.py

package info (click to toggle)
planet-venus 0~git9de2109-4.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,884 kB
  • sloc: python: 4,393; xml: 871; makefile: 39; sed: 3; sh: 2
file content (31 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python

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.parseString(source)
            except:
                self.fail('Not well formed: ' + doc);
                break
        else:
            self.assertTrue(True);