From edacbd56d1066bda08fa776de35068a663c1ff14 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 14 Jul 2016 01:10:57 +0900 Subject: [PATCH 01/15] Optimize tests: test_master_doc_not_found --- tests/test_build.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_build.py b/tests/test_build.py index 95910f60b..507a1cab3 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -17,7 +17,7 @@ from textwrap import dedent from sphinx.errors import SphinxError import sphinx.builders.linkcheck -from util import with_app, rootdir, tempdir, SkipTest, TestApp +from util import with_app, with_tempdir, rootdir, tempdir, SkipTest, TestApp try: from docutils.writers.manpage import Writer as ManWriter @@ -76,16 +76,19 @@ def test_build_all(): yield verify_build, buildername, srcdir -@with_app(buildername='text') -def test_master_doc_not_found(app, status, warning): - (app.srcdir / 'contents.txt').move(app.srcdir / 'contents.txt.bak') +@with_tempdir +def test_master_doc_not_found(tmpdir): + (tmpdir / 'conf.py').write_text('master_doc = "index"') + assert tmpdir.listdir() == ['conf.py'] + try: + app = TestApp(buildername='dummy', srcdir=tmpdir) app.builder.build_all() assert False # SphinxError not raised except Exception as exc: assert isinstance(exc, SphinxError) finally: - (app.srcdir / 'contents.txt.bak').move(app.srcdir / 'contents.txt') + app.cleanup() @with_app(buildername='text', testroot='circular') From 3fb439c476fa2013b8c7e3b95066b8e075b52c9b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 14 Jul 2016 01:35:54 +0900 Subject: [PATCH 02/15] Optimize tests: test_imgmath_png, test_imgmath_svg --- tests/roots/test-ext-math-simple/conf.py | 6 ++++++ tests/roots/test-ext-math-simple/index.rst | 4 ++++ tests/test_ext_math.py | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/roots/test-ext-math-simple/conf.py create mode 100644 tests/roots/test-ext-math-simple/index.rst diff --git a/tests/roots/test-ext-math-simple/conf.py b/tests/roots/test-ext-math-simple/conf.py new file mode 100644 index 000000000..3fe886c17 --- /dev/null +++ b/tests/roots/test-ext-math-simple/conf.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- + +master_doc = 'index' + +latex_documents = [ + (master_doc, 'test.tex', 'Math Extension Testing', 'Sphinx', 'report')] diff --git a/tests/roots/test-ext-math-simple/index.rst b/tests/roots/test-ext-math-simple/index.rst new file mode 100644 index 000000000..a455d8980 --- /dev/null +++ b/tests/roots/test-ext-math-simple/index.rst @@ -0,0 +1,4 @@ +Test Math +========= + +.. math:: a^2+b^2=c^2 diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 4b168b40c..517ba30c8 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -14,7 +14,7 @@ import re from util import with_app, SkipTest -@with_app('html', testroot='ext-math', +@with_app('html', testroot='ext-math-simple', confoverrides = {'extensions': ['sphinx.ext.imgmath']}) def test_imgmath_png(app, status, warning): app.builder.build_all() @@ -29,7 +29,7 @@ def test_imgmath_png(app, status, warning): assert re.search(html, content, re.S) -@with_app('html', testroot='ext-math', +@with_app('html', testroot='ext-math-simple', confoverrides={'extensions': ['sphinx.ext.imgmath'], 'imgmath_image_format': 'svg'}) def test_imgmath_svg(app, status, warning): From b95f450452976de371fabea6d93859acecb37f38 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 14 Jul 2016 01:20:49 +0900 Subject: [PATCH 03/15] Optimize tests: test_jsmath --- tests/roots/test-ext-math/math.rst | 31 ++++++++++++++++++++++++++++++ tests/test_build_html.py | 15 --------------- tests/test_ext_math.py | 16 +++++++++++++++ 3 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 tests/roots/test-ext-math/math.rst diff --git a/tests/roots/test-ext-math/math.rst b/tests/roots/test-ext-math/math.rst new file mode 100644 index 000000000..5a209bed4 --- /dev/null +++ b/tests/roots/test-ext-math/math.rst @@ -0,0 +1,31 @@ +Test math extensions :math:`E = m c^2` +====================================== + +This is inline math: :math:`a^2 + b^2 = c^2`. + +.. math:: a^2 + b^2 = c^2 + +.. math:: + + a + 1 < b + +.. math:: + :label: foo + + e^{i\pi} = 1 + +.. math:: + :label: + + e^{ix} = \cos x + i\sin x + +.. math:: + + n \in \mathbb N + +.. math:: + :nowrap: + + a + 1 < b + +Referencing equation :eq:`foo`. diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 7abefbcdc..a127b96e0 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -989,21 +989,6 @@ def test_enumerable_node(app, status, warning): yield check_xpath, etree, fname, xpath, check, be_found -@with_app(buildername='html') -def test_jsmath(app, status, warning): - app.builder.build_all() - content = (app.outdir / 'math.html').text() - - assert '
\na^2 + b^2 = c^2
' in content - assert '
\n\\begin{split}a + 1 < b\\end{split}
' in content - assert ('(1)
\n' - 'e^{i\\pi} = 1
' in content) - assert ('(2)
\n' - 'e^{ix} = \\cos x + i\\sin x
' in content) - assert '
\nn \\in \\mathbb N
' in content - assert '
\na + 1 < b
' in content - - @with_app(buildername='html', testroot='html_extra_path') def test_html_extra_path(app, status, warning): app.builder.build_all() diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 517ba30c8..c858afcd2 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -14,6 +14,22 @@ import re from util import with_app, SkipTest +@with_app(buildername='html', testroot='ext-math', + confoverrides = {'extensions': ['sphinx.ext.jsmath'], 'jsmath_path': 'dummy.js'}) +def test_jsmath(app, status, warning): + app.builder.build_all() + content = (app.outdir / 'math.html').text() + + assert '
\na^2 + b^2 = c^2
' in content + assert '
\n\\begin{split}a + 1 < b\\end{split}
' in content + assert ('(1)
\n' + 'e^{i\\pi} = 1
' in content) + assert ('(2)
\n' + 'e^{ix} = \\cos x + i\\sin x
' in content) + assert '
\nn \\in \\mathbb N
' in content + assert '
\na + 1 < b
' in content + + @with_app('html', testroot='ext-math-simple', confoverrides = {'extensions': ['sphinx.ext.imgmath']}) def test_imgmath_png(app, status, warning): From 5492b9ebc7416c8f107ac598c840c411e2380811 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 14 Jul 2016 01:45:55 +0900 Subject: [PATCH 04/15] Optimize tests: Remove test_i18n (duplicated with test_intl) --- tests/test_i18n.py | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 tests/test_i18n.py diff --git a/tests/test_i18n.py b/tests/test_i18n.py deleted file mode 100644 index fcb35fc42..000000000 --- a/tests/test_i18n.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- -""" - test_i18n - ~~~~~~~~~ - - Test locale features. - - :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" - -from util import with_app - - -@with_app(confoverrides={'language': 'de'}) -def test_i18n(app, status, warning): - app.builder.build_all() From c23a59b70c3045e06cbb6d25618a71fb86b83e52 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 14 Jul 2016 02:02:25 +0900 Subject: [PATCH 05/15] Optimize tests: test_searchadapters --- tests/roots/test-searchadapters/conf.py | 4 + tests/roots/test-searchadapters/markup.txt | 447 +++++++++++++++++++++ tests/test_searchadapters.py | 2 +- 3 files changed, 452 insertions(+), 1 deletion(-) create mode 100644 tests/roots/test-searchadapters/conf.py create mode 100644 tests/roots/test-searchadapters/markup.txt diff --git a/tests/roots/test-searchadapters/conf.py b/tests/roots/test-searchadapters/conf.py new file mode 100644 index 000000000..ade976ab5 --- /dev/null +++ b/tests/roots/test-searchadapters/conf.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +master_doc = 'markup' +source_suffix = '.txt' diff --git a/tests/roots/test-searchadapters/markup.txt b/tests/roots/test-searchadapters/markup.txt new file mode 100644 index 000000000..77f245a6f --- /dev/null +++ b/tests/roots/test-searchadapters/markup.txt @@ -0,0 +1,447 @@ +:tocdepth: 2 + +.. title:: set by title directive + +Testing various markup +====================== + +Meta markup +----------- + +.. sectionauthor:: Georg Brandl +.. moduleauthor:: Georg Brandl + +.. contents:: TOC + +.. meta:: + :author: Me + :keywords: docs, sphinx + + +Generic reST +------------ + +A |subst| (the definition is in rst_epilog). + +.. highlight:: none + +.. _label: + +:: + + some code + +Option list: + +-h help +--help also help + +Line block: + +| line1 +| line2 +| line3 +| line4 +| line5 +| line6 +| line7 + + +Body directives +^^^^^^^^^^^^^^^ + +.. topic:: Title + + Topic body. + +.. sidebar:: Sidebar + :subtitle: Sidebar subtitle + + Sidebar body. + +.. rubric:: Test rubric + +.. epigraph:: Epigraph title + + Epigraph body. + + -- Author + +.. highlights:: Highlights + + Highlights body. + +.. pull-quote:: Pull-quote + + Pull quote body. + +.. compound:: + + a + + b + +.. parsed-literal:: + + with some *markup* inside + + +.. _admonition-section: + +Admonitions +^^^^^^^^^^^ + +.. admonition:: My Admonition + + Admonition text. + +.. note:: + Note text. + +.. warning:: + + Warning text. + +.. _some-label: + +.. tip:: + Tip text. + +Indirect hyperlink targets + +.. _other-label: some-label_ + +Inline markup +------------- + +*Generic inline markup* + +Adding \n to test unescaping. + +* :command:`command\\n` +* :dfn:`dfn\\n` +* :guilabel:`guilabel with &accelerator and \\n` +* :kbd:`kbd\\n` +* :mailheader:`mailheader\\n` +* :makevar:`makevar\\n` +* :manpage:`manpage\\n` +* :mimetype:`mimetype\\n` +* :newsgroup:`newsgroup\\n` +* :program:`program\\n` +* :regexp:`regexp\\n` +* :menuselection:`File --> Close\\n` +* :menuselection:`&File --> &Print` +* :file:`a/{varpart}/b\\n` +* :samp:`print {i}\\n` + +*Linking inline markup* + +* :pep:`8` +* :pep:`Python Enhancement Proposal #8 <8>` +* :rfc:`1` +* :rfc:`Request for Comments #1 <1>` +* :envvar:`HOME` +* :keyword:`with` +* :token:`try statement ` +* :ref:`admonition-section` +* :ref:`here ` +* :ref:`there ` +* :ref:`my-figure` +* :ref:`my-figure-name` +* :ref:`my-table` +* :ref:`my-table-name` +* :ref:`my-code-block` +* :ref:`my-code-block-name` +* :numref:`my-figure` +* :numref:`my-figure-name` +* :numref:`my-table` +* :numref:`my-table-name` +* :numref:`my-code-block` +* :numref:`my-code-block-name` +* :doc:`subdir/includes` +* ``:download:`` is tested in includes.txt +* :option:`Python -c option ` +* This used to crash: :option:`&option` + +Test :abbr:`abbr (abbreviation)` and another :abbr:`abbr (abbreviation)`. + +Testing the :index:`index` role, also available with +:index:`explicit ` title. + +.. _with: + +With +---- + +(Empty section.) + + +Tables +------ + +.. tabularcolumns:: |L|p{5cm}|R| + +.. _my-table: + +.. table:: my table + :name: my-table-name + + +----+----------------+----+ + | 1 | * Block elems | x | + | | * In table | | + +----+----------------+----+ + | 2 | Empty cells: | | + +----+----------------+----+ + +.. table:: empty cell in table header + + ===== ====== + \ + ===== ====== + 1 2 + 3 4 + ===== ====== + +Tables with multirow and multicol: + +.. only:: latex + + +----+----------------+---------+ + | 1 | test! | c | + +----+---------+------+ | + | 2 | col | col | | + | y +---------+------+----+----+ + | x | multi-column cell | x | + +----+---------------------+----+ + + +----+ + | 1 | + + + + | | + +----+ + +.. list-table:: + :header-rows: 0 + + * - .. figure:: img.png + + figure in table + + +Figures +------- + +.. _my-figure: + +.. figure:: img.png + :name: my-figure-name + + My caption of the figure + + My description paragraph of the figure. + + Description paragraph is wraped with legend node. + +.. figure:: rimg.png + :align: right + + figure with align option + +.. figure:: rimg.png + :align: right + :figwidth: 50% + + figure with align & figwidth option + +.. figure:: rimg.png + :align: right + :width: 3cm + + figure with align & width option + +Version markup +-------------- + +.. versionadded:: 0.6 + Some funny **stuff**. + +.. versionchanged:: 0.6 + Even more funny stuff. + +.. deprecated:: 0.6 + Boring stuff. + +.. versionadded:: 1.2 + + First paragraph of versionadded. + +.. versionchanged:: 1.2 + First paragraph of versionchanged. + + Second paragraph of versionchanged. + + +Code blocks +----------- + +.. _my-code-block: + +.. code-block:: ruby + :linenos: + :caption: my ruby code + :name: my-code-block-name + + def ruby? + false + end + +.. code-block:: c + + import sys + + sys.stdout.write('hello world!\n') + + +Misc stuff +---------- + +Stuff [#]_ + +Reference lookup: [Ref1]_ (defined in another file). +Reference lookup underscore: [Ref_1]_ + +.. seealso:: something, something else, something more + + `Google `_ + For everything. + +.. hlist:: + :columns: 4 + + * This + * is + * a horizontal + * list + * with several + * items + +.. rubric:: Side note + +This is a side note. + +This tests :CLASS:`role names in uppercase`. + +.. centered:: LICENSE AGREEMENT + +.. acks:: + + * Terry Pratchett + * J. R. R. Tolkien + * Monty Python + +.. glossary:: + :sorted: + + boson + Particle with integer spin. + + *fermion* + Particle with half-integer spin. + + tauon + myon + electron + Examples for fermions. + + über + Gewisse + + änhlich + Dinge + +.. productionlist:: + try_stmt: `try1_stmt` | `try2_stmt` + try1_stmt: "try" ":" `suite` + : ("except" [`expression` ["," `target`]] ":" `suite`)+ + : ["else" ":" `suite`] + : ["finally" ":" `suite`] + try2_stmt: "try" ":" `suite` + : "finally" ":" `suite` + + +Index markup +------------ + +.. index:: + single: entry + pair: entry; pair + double: entry; double + triple: index; entry; triple + keyword: with + see: from; to + seealso: fromalso; toalso + +Invalid index markup... + +.. index:: + single: + pair: + keyword: + +.. index:: + !Main, !Other + !single: entry; pair + +:index:`!Main` + +.. _ölabel: + +Ö... Some strange characters +---------------------------- + +Testing öäü... + + +Only directive +-------------- + +.. only:: html + + In HTML. + +.. only:: latex + + In LaTeX. + +.. only:: html or latex + + In both. + +.. only:: confpytag and (testtag or nonexisting_tag) + + Always present, because set through conf.py/command line. + + +Any role +-------- + +.. default-role:: any + +Test referencing to `headings ` and `objects `. +Also `modules ` and `classes