From a75bf5af3c8af884db1c71d38de78e074901ae71 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Sat, 9 Jan 2016 17:33:51 -0800 Subject: [PATCH] Refactor the tests of math extensions. --- tests/roots/test-ext-imgmath/index.rst | 6 ----- .../conf.py | 1 - tests/roots/test-ext-math/index.rst | 10 ++++++++ .../{test_ext_imgmath.py => test_ext_math.py} | 25 ++++++++++++++----- 4 files changed, 29 insertions(+), 13 deletions(-) delete mode 100644 tests/roots/test-ext-imgmath/index.rst rename tests/roots/{test-ext-imgmath => test-ext-math}/conf.py (56%) create mode 100644 tests/roots/test-ext-math/index.rst rename tests/{test_ext_imgmath.py => test_ext_math.py} (63%) diff --git a/tests/roots/test-ext-imgmath/index.rst b/tests/roots/test-ext-imgmath/index.rst deleted file mode 100644 index f7780a422..000000000 --- a/tests/roots/test-ext-imgmath/index.rst +++ /dev/null @@ -1,6 +0,0 @@ -Test imgmath -============ - -.. math:: a^2+b^2=c^2 - -Inline :math:`E=mc^2` diff --git a/tests/roots/test-ext-imgmath/conf.py b/tests/roots/test-ext-math/conf.py similarity index 56% rename from tests/roots/test-ext-imgmath/conf.py rename to tests/roots/test-ext-math/conf.py index 3f3e2a783..f81c30bc4 100644 --- a/tests/roots/test-ext-imgmath/conf.py +++ b/tests/roots/test-ext-math/conf.py @@ -1,4 +1,3 @@ # -*- coding: utf-8 -*- -extensions = ['sphinx.ext.imgmath'] master_doc = 'index' diff --git a/tests/roots/test-ext-math/index.rst b/tests/roots/test-ext-math/index.rst new file mode 100644 index 000000000..491edda95 --- /dev/null +++ b/tests/roots/test-ext-math/index.rst @@ -0,0 +1,10 @@ +Test Math +========= + +.. math:: a^2+b^2=c^2 + +Inline :math:`E=mc^2` + +Second math + +.. math:: e^{i\pi}+1=0 diff --git a/tests/test_ext_imgmath.py b/tests/test_ext_math.py similarity index 63% rename from tests/test_ext_imgmath.py rename to tests/test_ext_math.py index 2e28d2baa..84bca95a3 100644 --- a/tests/test_ext_imgmath.py +++ b/tests/test_ext_math.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """ - test_ext_imgmath - ~~~~~~~~~~~~~~~~ + test_ext_math + ~~~~~~~~~~~~~ - Test sphinx.ext.imgmath extension. + Test math extensions. :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. @@ -14,7 +14,8 @@ import re from util import with_app, SkipTest -@with_app('html', testroot='ext-imgmath') +@with_app('html', testroot='ext-math', + confoverrides = {'extensions': ['sphinx.ext.imgmath']}) def test_imgmath_png(app, status, warning): app.builder.build_all() if "LaTeX command 'latex' cannot be run" in warning.getvalue(): @@ -27,8 +28,9 @@ def test_imgmath_png(app, status, warning): '\s*alt="a\^2\+b\^2=c\^2"/>\s*

\s*') assert re.search(html, content, re.S) -@with_app('html', testroot='ext-imgmath', - confoverrides={'imgmath_image_format': 'svg'}) +@with_app('html', testroot='ext-math', + confoverrides={'extensions': ['sphinx.ext.imgmath'], + 'imgmath_image_format': 'svg'}) def test_imgmath_svg(app, status, warning): app.builder.build_all() if "LaTeX command 'latex' cannot be run" in warning.getvalue(): @@ -40,3 +42,14 @@ def test_imgmath_svg(app, status, warning): html = ('
\s*

\s*\s*

\s*
') assert re.search(html, content, re.S) + +@with_app('html', testroot='ext-math', + confoverrides={'math_number_all': True, + 'extensions': ['sphinx.ext.mathjax']}) +def test_math_number_all(app, status, warning): + app.builder.build_all() + + content = (app.outdir / 'index.html').text() + html = (r'
\s*' + r'\(1\)\\\[a\^2\+b\^2=c\^2\\\]
') + assert re.search(html, content, re.S)