mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Refactor the tests of math extensions.
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
Test imgmath
|
|
||||||
============
|
|
||||||
|
|
||||||
.. math:: a^2+b^2=c^2
|
|
||||||
|
|
||||||
Inline :math:`E=mc^2`
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
extensions = ['sphinx.ext.imgmath']
|
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
@@ -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
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- 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.
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
@@ -14,7 +14,8 @@ import re
|
|||||||
from util import with_app, SkipTest
|
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):
|
def test_imgmath_png(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
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*</p>\s*</div>')
|
'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
|
||||||
assert re.search(html, content, re.S)
|
assert re.search(html, content, re.S)
|
||||||
|
|
||||||
@with_app('html', testroot='ext-imgmath',
|
@with_app('html', testroot='ext-math',
|
||||||
confoverrides={'imgmath_image_format': 'svg'})
|
confoverrides={'extensions': ['sphinx.ext.imgmath'],
|
||||||
|
'imgmath_image_format': 'svg'})
|
||||||
def test_imgmath_svg(app, status, warning):
|
def test_imgmath_svg(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
||||||
@@ -40,3 +42,14 @@ def test_imgmath_svg(app, status, warning):
|
|||||||
html = ('<div class="math">\s*<p>\s*<img src="_images/math/\w+.svg"'
|
html = ('<div class="math">\s*<p>\s*<img src="_images/math/\w+.svg"'
|
||||||
'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
|
'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
|
||||||
assert re.search(html, content, re.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'<div class="math">\s*'
|
||||||
|
r'<span class="eqno">\(1\)</span>\\\[a\^2\+b\^2=c\^2\\\]</div>')
|
||||||
|
assert re.search(html, content, re.S)
|
||||||
Reference in New Issue
Block a user