diff options
| author | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2014-12-05 16:42:30 +0900 |
|---|---|---|
| committer | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2014-12-05 16:42:30 +0900 |
| commit | edf63e1406a79be78c1285648621ecf77b4f6fc3 (patch) | |
| tree | eb3e244a7a4c4c84e0cc82ae5e46e81be0038aac /tests/test_build_html.py | |
| parent | 32e4fab86bebd9dacce176450f1ca591e89b1229 (diff) | |
| download | sphinx-git-edf63e1406a79be78c1285648621ecf77b4f6fc3.tar.gz | |
Fix again. Sections which depth are lower than :tocdepth: should not be shown on localtoc sidebar. Closes #1251
Diffstat (limited to 'tests/test_build_html.py')
| -rw-r--r-- | tests/test_build_html.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/test_build_html.py b/tests/test_build_html.py index c03465d5b..f0512aed3 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -323,13 +323,16 @@ def check_xpath(etree, fname, path, check, be_found=True): pass else: rex = re.compile(check) - for node in nodes: - if node.text and (bool(rex.search(node.text)) ^ (not be_found)): - break + if be_found: + if any(node.text and rex.search(node.text) for node in nodes): + return else: - assert False, ('%r not found in any node matching ' - 'path %s in %s: %r' % (check, path, fname, - [node.text for node in nodes])) + if all(node.text and not rex.search(node.text) 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])) def check_static_entries(outdir): @@ -396,12 +399,20 @@ def test_tocdepth(app, status, warning): (".//h3", '1.1.1. Foo A1', True), (".//h2", '1.2. Foo B', True), (".//h3", '1.2.1. Foo B1', 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), + (".//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), |
