summaryrefslogtreecommitdiff
path: root/tests/test_domain_cpp.py
diff options
context:
space:
mode:
authorJakob Lykke Andersen <Jakob@caput.dk>2016-01-28 13:19:23 +0900
committerJakob Lykke Andersen <Jakob@caput.dk>2016-01-28 13:19:23 +0900
commit5c363a683e61f471c8b6c3311a9ce42aeec09ca5 (patch)
tree566aece795526b7adb762e003ec3c6cdf5e9f173 /tests/test_domain_cpp.py
parent678f6066f5b3b0dfaaef52b51879f22f5b61696c (diff)
downloadsphinx-git-5c363a683e61f471c8b6c3311a9ce42aeec09ca5.tar.gz
Fix :cpp:any: fix_paren with explicit title.
Diffstat (limited to 'tests/test_domain_cpp.py')
-rw-r--r--tests/test_domain_cpp.py100
1 files changed, 64 insertions, 36 deletions
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index b4c795125..aef7e8ed4 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -397,47 +397,75 @@ def test_templates():
# raise DefinitionError("")
-@with_app(testroot='domain-cpp')
-def test_build_domain_cpp(app, status, warning):
+@with_app(testroot='domain-cpp', confoverrides={'add_function_parentheses': True})
+def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, warning):
app.builder.build_all()
- roles = (app.outdir / 'roles.html').text()
- assert re.search('<li><a .*?><code .*?><span .*?>Sphinx</span></code></a></li>', roles)
- assert re.search(('<li>ref function without parens <a .*?><code .*?><span .*?>'
- 'hello\(\)</span></code></a>\.</li>'), roles)
- assert re.search(('<li>ref function with parens <a .*?><code .*?><span .*?>'
- 'hello\(\)</span></code></a>\.</li>'), roles)
- assert re.search('<li><a .*?><code .*?><span .*?>Sphinx::version</span></code></a></li>',
- roles)
- assert re.search('<li><a .*?><code .*?><span .*?>version</span></code></a></li>', roles)
- assert re.search('<li><a .*?><code .*?><span .*?>List</span></code></a></li>', roles)
- assert re.search('<li><a .*?><code .*?><span .*?>MyEnum</span></code></a></li>', roles)
-
- any_role = (app.outdir / 'any-role.html').text()
- assert re.search('<li><a .*?><code .*?><span .*?>Sphinx</span></code></a></li>', any_role)
- assert re.search(('<li>ref function without parens <a .*?><code .*?><span .*?>'
- 'hello\(\)</span></code></a>\.</li>'), any_role)
- assert re.search(('<li>ref function with parens <a .*?><code .*?><span .*?>'
- 'hello\(\)</span></code></a>\.</li>'), any_role)
- assert re.search('<li><a .*?><code .*?><span .*?>Sphinx::version</span></code></a></li>',
- any_role)
- assert re.search('<li><a .*?><code .*?><span .*?>version</span></code></a></li>', any_role)
- assert re.search('<li><a .*?><code .*?><span .*?>List</span></code></a></li>', any_role)
- assert re.search('<li><a .*?><code .*?><span .*?>MyEnum</span></code></a></li>', any_role)
+ def check(spec, text, file):
+ pattern = '<li>%s<a .*?><code .*?><span .*?>%s</span></code></a></li>' % spec
+ res = re.search(pattern, text)
+ if not res:
+ print("Pattern\n\t%s\nnot found in %s" % (pattern, file))
+ assert False
+ rolePatterns = [
+ ('', 'Sphinx'),
+ ('', 'Sphinx::version'),
+ ('', 'version'),
+ ('', 'List'),
+ ('', 'MyEnum')
+ ]
+ parenPatterns = [
+ ('ref function without parens ', 'paren_1\(\)'),
+ ('ref function with parens ', 'paren_2\(\)'),
+ ('ref function without parens, explicit title ', 'paren_3_title'),
+ ('ref function with parens, explicit title ', 'paren_4_title')
+ ]
+
+ f = 'roles.html'
+ t = (app.outdir / f).text()
+ for s in rolePatterns:
+ check(s, t, f)
+ for s in parenPatterns:
+ check(s, t, f)
+
+ f = 'any-role.html'
+ t = (app.outdir / f).text()
+ for s in parenPatterns:
+ check(s, t, f)
@with_app(testroot='domain-cpp', confoverrides={'add_function_parentheses': False})
def test_build_domain_cpp_with_add_function_parentheses_is_False(app, status, warning):
app.builder.build_all()
- roles = (app.outdir / 'roles.html').text()
- assert re.search(('<li>ref function without parens <a .*?><code .*?><span .*?>'
- 'hello</span></code></a>\.</li>'), roles)
- assert re.search(('<li>ref function with parens <a .*?><code .*?><span .*?>'
- 'hello</span></code></a>\.</li>'), roles)
-
- any_role = (app.outdir / 'any-role.html').text()
- assert re.search(('<li>ref function without parens <a .*?><code .*?><span .*?>'
- 'hello</span></code></a>\.</li>'), any_role)
- assert re.search(('<li>ref function with parens <a .*?><code .*?><span .*?>'
- 'hello</span></code></a>\.</li>'), any_role)
+ def check(spec, text, file):
+ pattern = '<li>%s<a .*?><code .*?><span .*?>%s</span></code></a></li>' % spec
+ res = re.search(pattern, text)
+ if not res:
+ print("Pattern\n\t%s\nnot found in %s" % (pattern, file))
+ assert False
+ rolePatterns = [
+ ('', 'Sphinx'),
+ ('', 'Sphinx::version'),
+ ('', 'version'),
+ ('', 'List'),
+ ('', 'MyEnum')
+ ]
+ parenPatterns = [
+ ('ref function without parens ', 'paren_1'),
+ ('ref function with parens ', 'paren_2'),
+ ('ref function without parens, explicit title ', 'paren_3_title'),
+ ('ref function with parens, explicit title ', 'paren_4_title')
+ ]
+
+ f = 'roles.html'
+ t = (app.outdir / f).text()
+ for s in rolePatterns:
+ check(s, t, f)
+ for s in parenPatterns:
+ check(s, t, f)
+
+ f = 'any-role.html'
+ t = (app.outdir / f).text()
+ for s in parenPatterns:
+ check(s, t, f)