1
1
"""Test math extensions."""
2
2
3
3
import re
4
+ import shutil
4
5
import subprocess
5
6
import warnings
6
7
@@ -33,6 +34,7 @@ def test_imgmath_png(app, status, warning):
33
34
raise pytest .skip .Exception ('dvipng command "dvipng" is not available' )
34
35
35
36
content = (app .outdir / 'index.html' ).read_text (encoding = 'utf8' )
37
+ shutil .rmtree (app .outdir )
36
38
html = (r'<div class="math">\s*<p>\s*<img src="_images/math/\w+.png"'
37
39
r'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>' )
38
40
assert re .search (html , content , re .S )
@@ -51,6 +53,7 @@ def test_imgmath_svg(app, status, warning):
51
53
raise pytest .skip .Exception ('dvisvgm command "dvisvgm" is not available' )
52
54
53
55
content = (app .outdir / 'index.html' ).read_text (encoding = 'utf8' )
56
+ shutil .rmtree (app .outdir )
54
57
html = (r'<div class="math">\s*<p>\s*<img src="_images/math/\w+.svg"'
55
58
r'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>' )
56
59
assert re .search (html , content , re .S )
@@ -70,6 +73,7 @@ def test_imgmath_svg_embed(app, status, warning):
70
73
pytest .skip ('dvisvgm command "dvisvgm" is not available' )
71
74
72
75
content = (app .outdir / 'index.html' ).read_text (encoding = 'utf8' )
76
+ shutil .rmtree (app .outdir )
73
77
html = r'<img src="data:image/svg\+xml;base64,[\w\+/=]+"'
74
78
assert re .search (html , content , re .DOTALL )
75
79
@@ -81,6 +85,7 @@ def test_mathjax_options(app, status, warning):
81
85
app .builder .build_all ()
82
86
83
87
content = (app .outdir / 'index.html' ).read_text (encoding = 'utf8' )
88
+ shutil .rmtree (app .outdir )
84
89
assert ('<script async="async" integrity="sha384-0123456789" '
85
90
'src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">'
86
91
'</script>' in content )
@@ -92,6 +97,7 @@ def test_mathjax_align(app, status, warning):
92
97
app .builder .build_all ()
93
98
94
99
content = (app .outdir / 'index.html' ).read_text (encoding = 'utf8' )
100
+ shutil .rmtree (app .outdir )
95
101
html = (r'<div class="math notranslate nohighlight">\s*'
96
102
r'\\\[ \\begin\{align\}\\begin\{aligned\}S \&= \\pi r\^2\\\\'
97
103
r'V \&= \\frac\{4\}\{3\} \\pi r\^3\\end\{aligned\}\\end\{align\} \\\]</div>' )
0 commit comments