From 885b997a258c88a248f2f2a8514f717274103127 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 7 Dec 2015 11:02:45 +0900 Subject: [PATCH] Add testcases for latex_show_urls --- .../conf.py | 0 .../index.rst | 14 ++++-- .../rimg.png | Bin tests/test_build_latex.py | 45 +++++++++++++++++- 4 files changed, 55 insertions(+), 4 deletions(-) rename tests/roots/{test-references-in-caption => test-footnotes}/conf.py (100%) rename tests/roots/{test-references-in-caption => test-footnotes}/index.rst (68%) rename tests/roots/{test-references-in-caption => test-footnotes}/rimg.png (100%) diff --git a/tests/roots/test-references-in-caption/conf.py b/tests/roots/test-footnotes/conf.py similarity index 100% rename from tests/roots/test-references-in-caption/conf.py rename to tests/roots/test-footnotes/conf.py diff --git a/tests/roots/test-references-in-caption/index.rst b/tests/roots/test-footnotes/index.rst similarity index 68% rename from tests/roots/test-references-in-caption/index.rst rename to tests/roots/test-footnotes/index.rst index decec1bad..59211ad78 100644 --- a/tests/roots/test-references-in-caption/index.rst +++ b/tests/roots/test-footnotes/index.rst @@ -1,6 +1,6 @@ -============== -test-reference -============== +=============== +test-footenotes +=============== The section with a reference to [AuthorYear]_ ============================================= @@ -19,4 +19,12 @@ The section with a reference to [AuthorYear]_ .. rubric:: The rubric title with a reference to [AuthorYear]_ +* First footnote: [#]_ +* Second footnote: [1]_ +* `Sphinx `_ +* Third footnote: [#]_ + .. [AuthorYear] Author, Title, Year +.. [#] First +.. [1] Second +.. [#] Third diff --git a/tests/roots/test-references-in-caption/rimg.png b/tests/roots/test-footnotes/rimg.png similarity index 100% rename from tests/roots/test-references-in-caption/rimg.png rename to tests/roots/test-footnotes/rimg.png diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 00d3b82c1..7627e83b7 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -323,7 +323,7 @@ def test_footnote(app, status, warning): assert r'\footnote{sphinx-dev@googlegroups.com}' not in result -@with_app(buildername='latex', testroot='references-in-caption') +@with_app(buildername='latex', testroot='footnotes') def test_reference_in_caption(app, status, warning): app.builder.build_all() result = (app.outdir / 'Python.tex').text(encoding='utf8') @@ -335,3 +335,46 @@ def test_reference_in_caption(app, status, warning): assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result + + +@with_app(buildername='latex', testroot='footnotes', + confoverrides={'latex_show_urls': 'inline'}) +def test_latex_show_urls_is_inline(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'Python.tex').text(encoding='utf8') + print(result) + print(status.getvalue()) + print(warning.getvalue()) + assert 'First footnote: \\footnote[2]{\nFirst\n}' in result + assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result + assert '\\href{http://sphinx-doc.org/}{Sphinx} (http://sphinx-doc.org/)' in result + assert 'Third footnote: \\footnote[3]{\nThird\n}' in result + + +@with_app(buildername='latex', testroot='footnotes', + confoverrides={'latex_show_urls': 'footnote'}) +def test_latex_show_urls_is_footnote(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'Python.tex').text(encoding='utf8') + print(result) + print(status.getvalue()) + print(warning.getvalue()) + assert 'First footnote: \\footnote[2]{\nFirst\n}' in result + assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result + assert ('\\href{http://sphinx-doc.org/}{Sphinx}' + '\\footnote{http://sphinx-doc.org/}' in result) + assert 'Third footnote: \\footnote[3]{\nThird\n}' in result + + +@with_app(buildername='latex', testroot='footnotes', + confoverrides={'latex_show_urls': 'no'}) +def test_latex_show_urls_is_no(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'Python.tex').text(encoding='utf8') + print(result) + print(status.getvalue()) + print(warning.getvalue()) + assert 'First footnote: \\footnote[2]{\nFirst\n}' in result + assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result + assert '\\href{http://sphinx-doc.org/}{Sphinx}' in result + assert 'Third footnote: \\footnote[3]{\nThird\n}' in result