summaryrefslogtreecommitdiff
path: root/tests/test_build_html.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_build_html.py')
-rw-r--r--tests/test_build_html.py71
1 files changed, 45 insertions, 26 deletions
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index 3255bb71e..66164dd1c 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -97,14 +97,11 @@ def check_xpath(etree, fname, path, check, be_found=True):
else:
def get_text(node):
if node.text is not None:
+ # the node has only one text
return node.text
else:
- # Since pygments-2.1.1, empty <span> tag is inserted at top of
- # highlighting block
- if len(node) == 1 and node[0].tag == 'span' and node[0].text is None:
- if node[0].tail is not None:
- return node[0].tail
- return ''
+ # the node has tags and text; gather texts just under the node
+ return ''.join(n.tail or '' for n in node)
rex = re.compile(check)
if be_found:
@@ -491,28 +488,40 @@ def test_html_translator(app):
(".//li[@class='toctree-l3']/a", '2.2.1. Bar B1', False),
],
'foo.html': [
- (".//h1", '1. Foo', True),
- (".//h2", '1.1. Foo A', True),
- (".//h3", '1.1.1. Foo A1', True),
- (".//h2", '1.2. Foo B', True),
- (".//h3", '1.2.1. Foo B1', True),
+ (".//h1", 'Foo', True),
+ (".//h2", 'Foo A', True),
+ (".//h3", 'Foo A1', True),
+ (".//h2", 'Foo B', True),
+ (".//h3", 'Foo B1', True),
+
+ (".//h1//span[@class='section-number']", '1. ', True),
+ (".//h2//span[@class='section-number']", '1.1. ', True),
+ (".//h3//span[@class='section-number']", '1.1.1. ', True),
+ (".//h2//span[@class='section-number']", '1.2. ', True),
+ (".//h3//span[@class='section-number']", '1.2.1. ', True),
+
(".//div[@class='sphinxsidebarwrapper']//li/a", '1.1. Foo A', True),
(".//div[@class='sphinxsidebarwrapper']//li/a", '1.1.1. Foo A1', True),
(".//div[@class='sphinxsidebarwrapper']//li/a", '1.2. Foo B', True),
(".//div[@class='sphinxsidebarwrapper']//li/a", '1.2.1. Foo B1', True),
],
'bar.html': [
- (".//h1", '2. Bar', True),
- (".//h2", '2.1. Bar A', True),
- (".//h2", '2.2. Bar B', True),
- (".//h3", '2.2.1. Bar B1', True),
+ (".//h1", 'Bar', True),
+ (".//h2", 'Bar A', True),
+ (".//h2", 'Bar B', True),
+ (".//h3", 'Bar B1', True),
+ (".//h1//span[@class='section-number']", '2. ', True),
+ (".//h2//span[@class='section-number']", '2.1. ', True),
+ (".//h2//span[@class='section-number']", '2.2. ', True),
+ (".//h3//span[@class='section-number']", '2.2.1. ', True),
(".//div[@class='sphinxsidebarwrapper']//li/a", '2. Bar', True),
(".//div[@class='sphinxsidebarwrapper']//li/a", '2.1. Bar A', True),
(".//div[@class='sphinxsidebarwrapper']//li/a", '2.2. Bar B', True),
(".//div[@class='sphinxsidebarwrapper']//li/a", '2.2.1. Bar B1', False),
],
'baz.html': [
- (".//h1", '2.1.1. Baz A', True),
+ (".//h1", 'Baz A', True),
+ (".//h1//span[@class='section-number']", '2.1.1. ', True),
],
}))
@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
@@ -536,20 +545,30 @@ def test_tocdepth(app, cached_etree_parse, fname, expect):
(".//h1", 'test-tocdepth', True),
# foo.rst
- (".//h2", '1. Foo', True),
- (".//h3", '1.1. Foo A', True),
- (".//h4", '1.1.1. Foo A1', True),
- (".//h3", '1.2. Foo B', True),
- (".//h4", '1.2.1. Foo B1', True),
+ (".//h2", 'Foo', True),
+ (".//h3", 'Foo A', True),
+ (".//h4", 'Foo A1', True),
+ (".//h3", 'Foo B', True),
+ (".//h4", 'Foo B1', True),
+ (".//h2//span[@class='section-number']", '1. ', True),
+ (".//h3//span[@class='section-number']", '1.1. ', True),
+ (".//h4//span[@class='section-number']", '1.1.1. ', True),
+ (".//h3//span[@class='section-number']", '1.2. ', True),
+ (".//h4//span[@class='section-number']", '1.2.1. ', True),
# bar.rst
- (".//h2", '2. Bar', True),
- (".//h3", '2.1. Bar A', True),
- (".//h3", '2.2. Bar B', True),
- (".//h4", '2.2.1. Bar B1', True),
+ (".//h2", 'Bar', True),
+ (".//h3", 'Bar A', True),
+ (".//h3", 'Bar B', True),
+ (".//h4", 'Bar B1', True),
+ (".//h2//span[@class='section-number']", '2. ', True),
+ (".//h3//span[@class='section-number']", '2.1. ', True),
+ (".//h3//span[@class='section-number']", '2.2. ', True),
+ (".//h4//span[@class='section-number']", '2.2.1. ', True),
# baz.rst
- (".//h4", '2.1.1. Baz A', True),
+ (".//h4", 'Baz A', True),
+ (".//h4//span[@class='section-number']", '2.1.1. ', True),
],
}))
@pytest.mark.skipif(docutils.__version_info__ < (0, 13),