mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5985 from tk0miya/refactor_test_build_html
refactor: test_build_html.py
This commit is contained in:
commit
3fbb599d23
@ -10,20 +10,16 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import xml.etree.cElementTree as ElementTree
|
|
||||||
from itertools import cycle, chain
|
from itertools import cycle, chain
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from html5lib import getTreeBuilder, HTMLParser
|
from html5lib import HTMLParser
|
||||||
|
|
||||||
from sphinx.errors import ConfigError
|
from sphinx.errors import ConfigError
|
||||||
from sphinx.testing.util import strip_escseq
|
from sphinx.testing.util import strip_escseq
|
||||||
from sphinx.util.inventory import InventoryFile
|
from sphinx.util.inventory import InventoryFile
|
||||||
|
|
||||||
|
|
||||||
TREE_BUILDER = getTreeBuilder('etree', implementation=ElementTree)
|
|
||||||
HTML_PARSER = HTMLParser(TREE_BUILDER, namespaceHTMLElements=False)
|
|
||||||
|
|
||||||
ENV_WARNINGS = """\
|
ENV_WARNINGS = """\
|
||||||
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
|
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
|
||||||
WARNING: Explicit markup ends without a blank line; unexpected unindent.
|
WARNING: Explicit markup ends without a blank line; unexpected unindent.
|
||||||
@ -53,7 +49,7 @@ def cached_etree_parse():
|
|||||||
if fname in etree_cache:
|
if fname in etree_cache:
|
||||||
return etree_cache[fname]
|
return etree_cache[fname]
|
||||||
with (fname).open('rb') as fp:
|
with (fname).open('rb') as fp:
|
||||||
etree = HTML_PARSER.parse(fp)
|
etree = HTMLParser(namespaceHTMLElements=False).parse(fp)
|
||||||
etree_cache.clear()
|
etree_cache.clear()
|
||||||
etree_cache[fname] = etree
|
etree_cache[fname] = etree
|
||||||
return etree
|
return etree
|
||||||
|
@ -14,18 +14,14 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import xml.etree.cElementTree as ElementTree
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from html5lib import getTreeBuilder, HTMLParser
|
from html5lib import HTMLParser
|
||||||
from test_build_html import flat_dict, tail_check, check_xpath
|
from test_build_html import flat_dict, tail_check, check_xpath
|
||||||
|
|
||||||
from sphinx.util.docutils import is_html5_writer_available
|
from sphinx.util.docutils import is_html5_writer_available
|
||||||
|
|
||||||
TREE_BUILDER = getTreeBuilder('etree', implementation=ElementTree)
|
|
||||||
HTML_PARSER = HTMLParser(TREE_BUILDER, namespaceHTMLElements=False)
|
|
||||||
|
|
||||||
|
|
||||||
etree_cache = {}
|
etree_cache = {}
|
||||||
|
|
||||||
@ -37,7 +33,7 @@ def cached_etree_parse():
|
|||||||
if fname in etree_cache:
|
if fname in etree_cache:
|
||||||
return etree_cache[fname]
|
return etree_cache[fname]
|
||||||
with (fname).open('rb') as fp:
|
with (fname).open('rb') as fp:
|
||||||
etree = HTML_PARSER.parse(fp)
|
etree = HTMLParser(namespaceHTMLElements=False).parse(fp)
|
||||||
etree_cache.clear()
|
etree_cache.clear()
|
||||||
etree_cache[fname] = etree
|
etree_cache[fname] = etree
|
||||||
return etree
|
return etree
|
||||||
|
Loading…
Reference in New Issue
Block a user