Merge pull request #5985 from tk0miya/refactor_test_build_html

refactor: test_build_html.py
This commit is contained in:
Takeshi KOMIYA 2019-02-04 01:59:21 +09:00 committed by GitHub
commit 3fbb599d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 12 deletions

View File

@ -10,20 +10,16 @@
import os
import re
import xml.etree.cElementTree as ElementTree
from itertools import cycle, chain
import pytest
from html5lib import getTreeBuilder, HTMLParser
from html5lib import HTMLParser
from sphinx.errors import ConfigError
from sphinx.testing.util import strip_escseq
from sphinx.util.inventory import InventoryFile
TREE_BUILDER = getTreeBuilder('etree', implementation=ElementTree)
HTML_PARSER = HTMLParser(TREE_BUILDER, namespaceHTMLElements=False)
ENV_WARNINGS = """\
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
WARNING: Explicit markup ends without a blank line; unexpected unindent.
@ -53,7 +49,7 @@ def cached_etree_parse():
if fname in etree_cache:
return etree_cache[fname]
with (fname).open('rb') as fp:
etree = HTML_PARSER.parse(fp)
etree = HTMLParser(namespaceHTMLElements=False).parse(fp)
etree_cache.clear()
etree_cache[fname] = etree
return etree

View File

@ -14,18 +14,14 @@
"""
import re
import xml.etree.cElementTree as ElementTree
from hashlib import md5
import pytest
from html5lib import getTreeBuilder, HTMLParser
from html5lib import HTMLParser
from test_build_html import flat_dict, tail_check, check_xpath
from sphinx.util.docutils import is_html5_writer_available
TREE_BUILDER = getTreeBuilder('etree', implementation=ElementTree)
HTML_PARSER = HTMLParser(TREE_BUILDER, namespaceHTMLElements=False)
etree_cache = {}
@ -37,7 +33,7 @@ def cached_etree_parse():
if fname in etree_cache:
return etree_cache[fname]
with (fname).open('rb') as fp:
etree = HTML_PARSER.parse(fp)
etree = HTMLParser(namespaceHTMLElements=False).parse(fp)
etree_cache.clear()
etree_cache[fname] = etree
return etree