diff options
| author | Jakob Lykke Andersen <Jakob@caput.dk> | 2016-01-28 13:19:23 +0900 |
|---|---|---|
| committer | Jakob Lykke Andersen <Jakob@caput.dk> | 2016-01-28 13:19:23 +0900 |
| commit | 5c363a683e61f471c8b6c3311a9ce42aeec09ca5 (patch) | |
| tree | 566aece795526b7adb762e003ec3c6cdf5e9f173 /tests/test_domain_cpp.py | |
| parent | 678f6066f5b3b0dfaaef52b51879f22f5b61696c (diff) | |
| download | sphinx-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.py | 100 |
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) |
