diff options
author | tk0miya <i.tkomiya@gmail.com> | 2014-10-02 11:17:34 +0900 |
---|---|---|
committer | tk0miya <i.tkomiya@gmail.com> | 2014-10-02 11:17:34 +0900 |
commit | cc9a87aaf5c78bb144fee46b8cb71052494f0ec8 (patch) | |
tree | 36b6115f0e27314492ed4651f89b04f9a461bf2b | |
parent | a20ab55213026a48c0fef2c8f13acba73bfe3fcd (diff) | |
download | sphinx-cc9a87aaf5c78bb144fee46b8cb71052494f0ec8.tar.gz |
Update testcases for :numref:
-rw-r--r-- | tests/root/conf.py | 1 | ||||
-rw-r--r-- | tests/root/markup.txt | 3 | ||||
-rw-r--r-- | tests/roots/test-numfig/baz.rst | 6 | ||||
-rw-r--r-- | tests/roots/test-numfig/index.rst | 14 | ||||
-rw-r--r-- | tests/test_build_html.py | 33 | ||||
-rw-r--r-- | tests/test_build_latex.py | 16 |
6 files changed, 71 insertions, 2 deletions
diff --git a/tests/root/conf.py b/tests/root/conf.py index d12e8167..5186f371 100644 --- a/tests/root/conf.py +++ b/tests/root/conf.py @@ -24,6 +24,7 @@ exclude_patterns = ['_build', '**/excluded.*'] keep_warnings = True pygments_style = 'sphinx' show_authors = True +numfig = True rst_epilog = '.. |subst| replace:: global substitution' diff --git a/tests/root/markup.txt b/tests/root/markup.txt index 6ed396ac..1ad7a13b 100644 --- a/tests/root/markup.txt +++ b/tests/root/markup.txt @@ -143,6 +143,9 @@ Adding \n to test unescaping. * :ref:`my-figure` * :ref:`my-table` * :ref:`my-code-block` +* :numref:`my-figure` +* :numref:`my-table` +* :numref:`my-code-block` * :doc:`subdir/includes` * ``:download:`` is tested in includes.txt * :option:`Python -c option <python -c>` diff --git a/tests/roots/test-numfig/baz.rst b/tests/roots/test-numfig/baz.rst index 9e2ccfeb..da9e0fe0 100644 --- a/tests/roots/test-numfig/baz.rst +++ b/tests/roots/test-numfig/baz.rst @@ -1,15 +1,21 @@ Baz A ----- +.. _fig22: + .. figure:: rimg.png should be Fig.2.2 +.. _table22: + .. csv-table:: should be Table 2.2 :header-rows: 0 hello,world +.. _code22: + .. code-block:: python :caption: should be List 2.2 diff --git a/tests/roots/test-numfig/index.rst b/tests/roots/test-numfig/index.rst index 564018e3..7bdf135c 100644 --- a/tests/roots/test-numfig/index.rst +++ b/tests/roots/test-numfig/index.rst @@ -7,6 +7,8 @@ test-tocdepth foo bar +.. _fig1: + .. figure:: rimg.png should be Fig.1 @@ -15,6 +17,8 @@ test-tocdepth should be Fig.2 +.. _table1: + .. csv-table:: should be Table 1 :header-rows: 0 @@ -25,6 +29,8 @@ test-tocdepth hello,world +.. _code1: + .. code-block:: python :caption: should be List 1 @@ -34,3 +40,11 @@ test-tocdepth :caption: should be List 2 print('hello world') + + +* Fig.1 is :numref:`fig1` +* Fig.2.2 is :numref:`Figure# <fig22>` +* Table.1 is :numref:`table1` +* Table.2.2 is :numref:`Table:# <table22>` +* List.1 is :numref:`code1` +* List.2.2 is :numref:`Code-# <code22>` diff --git a/tests/test_build_html.py b/tests/test_build_html.py index ae518062..6d71c7a6 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -458,8 +458,7 @@ def test_tocdepth_singlehtml(app, status, warning): @gen_with_app(buildername='html', testroot='numfig') -def test_numfig(app, status, warning): - # issue #1251 +def test_numfig_disabled(app, status, warning): app.builder.build_all() expects = { @@ -474,6 +473,12 @@ def test_numfig(app, status, warning): '^should be List 1$', True), (".//div[@class='code-block-caption']", '^should be List 2$', True), + (".//li/code/span", '^fig1$', True), + (".//li/code/span", '^Figure#$', True), + (".//li/code/span", '^table1$', True), + (".//li/code/span", '^Table:#$', True), + (".//li/code/span", '^code1$', True), + (".//li/code/span", '^Code-#$', True), ], 'foo.html': [ (".//div[@class='figure']/p[@class='caption']", @@ -557,6 +562,12 @@ def test_numfig_without_numbered_toctree(app, status, warning): '^List 9 should be List 1$', True), (".//div[@class='code-block-caption']", '^List 10 should be List 2$', True), + (".//li/a/em", '^Fig.9$', True), + (".//li/a/em", '^Figure6$', True), + (".//li/a/em", '^Table 9$', True), + (".//li/a/em", '^Table:6$', True), + (".//li/a/em", '^List 9$', True), + (".//li/a/em", '^Code-6$', True), ], 'foo.html': [ (".//div[@class='figure']/p[@class='caption']", @@ -636,6 +647,12 @@ def test_numfig_with_numbered_toctree(app, status, warning): '^List 1 should be List 1$', True), (".//div[@class='code-block-caption']", '^List 2 should be List 2$', True), + (".//li/a/em", '^Fig.1$', True), + (".//li/a/em", '^Figure2.2$', True), + (".//li/a/em", '^Table 1$', True), + (".//li/a/em", '^Table:2.2$', True), + (".//li/a/em", '^List 1$', True), + (".//li/a/em", '^Code-2.2$', True), ], 'foo.html': [ (".//div[@class='figure']/p[@class='caption']", @@ -715,6 +732,12 @@ def test_numfig_with_prefix(app, status, warning): '^Code-1 should be List 1$', True), (".//div[@class='code-block-caption']", '^Code-2 should be List 2$', True), + (".//li/a/em", '^Figure:1$', True), + (".//li/a/em", '^Figure2.2$', True), + (".//li/a/em", '^Tab_1$', True), + (".//li/a/em", '^Table:2.2$', True), + (".//li/a/em", '^Code-1$', True), + (".//li/a/em", '^Code-2.2$', True), ], 'foo.html': [ (".//div[@class='figure']/p[@class='caption']", @@ -794,6 +817,12 @@ def test_numfig_with_secnum_depth(app, status, warning): '^List 1 should be List 1$', True), (".//div[@class='code-block-caption']", '^List 2 should be List 2$', True), + (".//li/a/em", '^Fig.1$', True), + (".//li/a/em", '^Figure2.1.2$', True), + (".//li/a/em", '^Table 1$', True), + (".//li/a/em", '^Table:2.1.2$', True), + (".//li/a/em", '^List 1$', True), + (".//li/a/em", '^Code-2.1.2$', True), ], 'foo.html': [ (".//div[@class='figure']/p[@class='caption']", diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 374b54a2..3b6dd3e2 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -93,6 +93,22 @@ def test_latex(app, status, warning): os.chdir(cwd) +@with_app(buildername='latex', testroot='numfig', + confoverrides={'numfig': True}) +def test_numref(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'Python.tex').text(encoding='utf8') + print(result) + print(status.getvalue()) + print(warning.getvalue()) + assert '\\ref{index:fig1}' in result + assert '\\ref{baz:fig22}' in result + assert '\\ref{index:table1}' in result + assert '\\ref{baz:table22}' in result + assert '\\ref{index:code1}' in result + assert '\\ref{baz:code22}' in result + + @with_app(buildername='latex') def test_latex_add_latex_package(app, status, warning): app.add_latex_package('foo') |