Created
August 6, 2019 11:35
-
-
Save yves-chevallier/cc699e8b5d259b727242c152efd3b6bb to your computer and use it in GitHub Desktop.
Sphinx test error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
________________________________________________________________________________________________ test_tocdepth_singlehtml[index.html-expect14] ________________________________________________________________________________________________ | |
app = <sphinx.testing.util.SphinxTestAppWrapperForSkipBuilding object at 0x7f51ea4776d8>, cached_etree_parse = <function cached_etree_parse.<locals>.parse at 0x7f51ec7671e0>, fname = 'index.html', expect = ('.//h4', '2.1.1. Baz A', True) | |
@pytest.mark.parametrize("fname,expect", flat_dict({ | |
'index.html': [ | |
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True), | |
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True), | |
(".//li[@class='toctree-l3']/a", '2.1.1. Bar A1', False), | |
(".//li[@class='toctree-l3']/a", '2.2.1. Bar B1', False), | |
# index.rst | |
(".//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), | |
# 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), | |
# baz.rst | |
(".//h4", '2.1.1. Baz A', True), | |
], | |
})) | |
@pytest.mark.skipif(docutils.__version_info__ < (0, 13), | |
reason='docutils-0.13 or above is required') | |
@pytest.mark.sphinx('singlehtml', testroot='tocdepth') | |
@pytest.mark.test_params(shared_result='test_build_html_tocdepth') | |
def test_tocdepth_singlehtml(app, cached_etree_parse, fname, expect): | |
app.build() | |
> check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect) | |
tests/test_build_html.py:561: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
etree = <Element 'html' at 0x7f51eb07aa48>, fname = 'index.html', path = './/h4', check = '2.1.1. Baz A', be_found = True | |
def check_xpath(etree, fname, path, check, be_found=True): | |
nodes = list(etree.findall(path)) | |
if check is None: | |
assert nodes == [], ('found any nodes matching xpath ' | |
'%r in file %s' % (path, fname)) | |
return | |
else: | |
assert nodes != [], ('did not find any node matching xpath ' | |
'%r in file %s' % (path, fname)) | |
if hasattr(check, '__call__'): | |
check(nodes) | |
elif not check: | |
# only check for node presence | |
pass | |
else: | |
def get_text(node): | |
if node.text is not None: | |
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 '' | |
rex = re.compile(check) | |
if be_found: | |
if any(rex.search(get_text(node)) for node in nodes): | |
return | |
else: | |
if all(not rex.search(get_text(node)) for node in nodes): | |
return | |
> assert False, ('%r not found in any node matching ' | |
'path %s in %s: %r' % (check, path, fname, | |
[node.text for node in nodes])) | |
E AssertionError: '2.1.1. Baz A' not found in any node matching path .//h4 in index.html: [None, None, None, None] | |
E assert False | |
tests/test_build_html.py:117: AssertionError | |
---------------------------------------------------------------------------------------------------------- Captured stdout teardown ----------------------------------------------------------------------------------------------------------- | |
# testroot: root | |
# builder: singlehtml | |
# srcdir: /tmp/pytest-of-ycr/pytest-12/test_build_html_tocdepth | |
# outdir: /tmp/pytest-of-ycr/pytest-12/test_build_html_tocdepth/_build/singlehtml | |
# status: | |
Running Sphinx v2.2.0+/c3545922e | |
loading pickled environment... done | |
s that are out of date | |
building [html]: targets for 4 source files that are out of date | |
updating environment: 4 added, 0 changed, 0 removed | |
reading sources... [100%] index | |
looking for now-outdated files... none found | |
pickling environment... done | |
checking consistency... done | |
preparing documents... done | |
writing output... [100%] index | |
generating indices... genindexdone | |
writing additional pages... searchdone | |
copying static files... ... done | |
copying extra files... done | |
dumping search index in English (code: en)... done | |
dumping object inventory... done | |
build succeeded. | |
The HTML pages are in ../../../../../../tmp/pytest-of-ycr/pytest-12/test_build_html_tocdepth/_build/html. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment