@@ -18,6 +18,7 @@ def test_tinypages(tmp_path):
18
18
shutil .copytree (Path (__file__ ).parent / 'tinypages' , tmp_path ,
19
19
dirs_exist_ok = True )
20
20
html_dir = tmp_path / '_build' / 'html'
21
+ img_dir = html_dir / '_images'
21
22
doctree_dir = tmp_path / 'doctrees'
22
23
# Build the pages with warnings turned into errors
23
24
cmd = [sys .executable , '-msphinx' , '-W' , '-b' , 'html' ,
@@ -35,7 +36,7 @@ def test_tinypages(tmp_path):
35
36
build_sphinx_html (tmp_path , doctree_dir , html_dir )
36
37
37
38
def plot_file (num ):
38
- return html_dir / f'some_plots-{ num } .png'
39
+ return img_dir / f'some_plots-{ num } .png'
39
40
40
41
def plot_directive_file (num ):
41
42
# This is always next to the doctree dir.
@@ -58,8 +59,8 @@ def plot_directive_file(num):
58
59
59
60
assert b'# Only a comment' in html_contents
60
61
# check plot defined in external file.
61
- assert filecmp .cmp (range_4 , html_dir / 'range4.png' )
62
- assert filecmp .cmp (range_6 , html_dir / 'range6.png' )
62
+ assert filecmp .cmp (range_4 , img_dir / 'range4.png' )
63
+ assert filecmp .cmp (range_6 , img_dir / 'range6.png' )
63
64
# check if figure caption made it into html file
64
65
assert b'This is the caption for plot 15.' in html_contents
65
66
# check if figure caption using :caption: made it into html file
@@ -111,13 +112,13 @@ def test_plot_html_show_source_link(tmp_path):
111
112
# Make sure source scripts are created by default
112
113
html_dir1 = tmp_path / '_build' / 'html1'
113
114
build_sphinx_html (tmp_path , doctree_dir , html_dir1 )
114
- assert " index-1.py" in [ p . name for p in html_dir1 . iterdir ()]
115
+ assert len ( list ( html_dir1 . glob ( "**/ index-1.py"))) == 1
115
116
# Make sure source scripts are NOT created when
116
117
# plot_html_show_source_link` is False
117
118
html_dir2 = tmp_path / '_build' / 'html2'
118
119
build_sphinx_html (tmp_path , doctree_dir , html_dir2 ,
119
120
extra_args = ['-D' , 'plot_html_show_source_link=0' ])
120
- assert " index-1.py" not in [ p . name for p in html_dir2 . iterdir ()]
121
+ assert len ( list ( html_dir2 . glob ( "**/ index-1.py"))) == 0
121
122
122
123
123
124
@pytest .mark .parametrize ('plot_html_show_source_link' , [0 , 1 ])
@@ -137,7 +138,7 @@ def test_show_source_link_true(tmp_path, plot_html_show_source_link):
137
138
html_dir = tmp_path / '_build' / 'html'
138
139
build_sphinx_html (tmp_path , doctree_dir , html_dir , extra_args = [
139
140
'-D' , f'plot_html_show_source_link={ plot_html_show_source_link } ' ])
140
- assert " index-1.py" in [ p . name for p in html_dir . iterdir ()]
141
+ assert len ( list ( html_dir . glob ( "**/ index-1.py"))) == 1
141
142
142
143
143
144
@pytest .mark .parametrize ('plot_html_show_source_link' , [0 , 1 ])
@@ -157,7 +158,7 @@ def test_show_source_link_false(tmp_path, plot_html_show_source_link):
157
158
html_dir = tmp_path / '_build' / 'html'
158
159
build_sphinx_html (tmp_path , doctree_dir , html_dir , extra_args = [
159
160
'-D' , f'plot_html_show_source_link={ plot_html_show_source_link } ' ])
160
- assert " index-1.py" not in [ p . name for p in html_dir . iterdir ()]
161
+ assert len ( list ( html_dir . glob ( "**/ index-1.py"))) == 0
161
162
162
163
163
164
def build_sphinx_html (tmp_path , doctree_dir , html_dir , extra_args = None ):
0 commit comments