Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e625e9

Browse files
Update test
1 parent 314f58a commit 3e625e9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/tests/test_sphinxext.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def test_tinypages(tmpdir):
1818
source_dir = Path(tmpdir) / 'src'
1919
shutil.copytree(Path(__file__).parent / 'tinypages', source_dir)
2020
html_dir = source_dir / '_build' / 'html'
21+
img_dir = html_dir / '_images'
2122
doctree_dir = source_dir / 'doctrees'
2223
# Build the pages with warnings turned into errors
2324
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
@@ -35,7 +36,7 @@ def test_tinypages(tmpdir):
3536
build_sphinx_html(source_dir, doctree_dir, html_dir)
3637

3738
def plot_file(num):
38-
return html_dir / f'some_plots-{num}.png'
39+
return img_dir / f'some_plots-{num}.png'
3940

4041
def plot_directive_file(num):
4142
# This is always next to the doctree dir.
@@ -58,8 +59,8 @@ def plot_directive_file(num):
5859

5960
assert b'# Only a comment' in html_contents
6061
# 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')
6364
# check if figure caption made it into html file
6465
assert b'This is the caption for plot 15.' in html_contents
6566
# check if figure caption using :caption: made it into html file
@@ -113,13 +114,13 @@ def test_plot_html_show_source_link(tmpdir):
113114
# Make sure source scripts are created by default
114115
html_dir1 = source_dir / '_build' / 'html1'
115116
build_sphinx_html(source_dir, doctree_dir, html_dir1)
116-
assert "index-1.py" in [p.name for p in html_dir1.iterdir()]
117+
assert len(list(html_dir1.glob("**/index-1.py"))) == 1
117118
# Make sure source scripts are NOT created when
118119
# plot_html_show_source_link` is False
119120
html_dir2 = source_dir / '_build' / 'html2'
120121
build_sphinx_html(source_dir, doctree_dir, html_dir2,
121122
extra_args=['-D', 'plot_html_show_source_link=0'])
122-
assert "index-1.py" not in [p.name for p in html_dir2.iterdir()]
123+
assert len(list(html_dir2.glob("**/index-1.py"))) == 0
123124

124125

125126
def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):

0 commit comments

Comments
 (0)