8000 Use shutil.ignore_patterns · matplotlib/matplotlib@bab3aaf · GitHub
[go: up one dir, main page]

Skip to content

Commit bab3aaf

Browse files
committed
Use shutil.ignore_patterns
1 parent d4f2440 commit bab3aaf

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

lib/matplotlib/tests/test_sphinxext.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@
1616
tinypages = Path(__file__).parent / 'data/tinypages'
1717

1818

19-
def _ignore_build_artifacts(dir, files):
20-
"""
21-
Ignore function for shutil.copytree to exclude build artifacts.
22-
23-
This prevents stale build artifacts from the source tinypages directory
24-
from being copied to test directories, which could cause inconsistent
25-
test results due to cached or outdated files.
26-
"""
27-
return {'_build', 'doctrees', 'plot_directive'} & set(files)
28-
29-
3019
def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
3120
# Build the pages with warnings turned into errors
3221
extra_args = [] if extra_args is None else extra_args
@@ -52,7 +41,8 @@ def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
5241

5342
def test_tinypages(tmp_path):
5443
shutil.copytree(tinypages, tmp_path, dirs_exist_ok=True,
55-
ignore=_ignore_build_artifacts)
44+
ignore=shutil.ignore_patterns('_build', 'doctrees',
45+
'plot_directive'))
5646
html_dir = tmp_path / '_build' / 'html'
5747
img_dir = html_dir / '_images'
5848
doctree_dir = tmp_path / 'doctrees'
@@ -217,7 +207,8 @@ def test_plot_html_show_source_link_custom_basename(tmp_path):
217207

218208
def test_srcset_version(tmp_path):
219209
shutil.copytree(tinypages, tmp_path, dirs_exist_ok=True,
220-
ignore=_ignore_build_artifacts)
210+
ignore=shutil.ignore_patterns('_build', 'doctrees',
211+
'plot_directive'))
221212
html_dir = tmp_path / '_build' / 'html'
222213
img_dir = html_dir / '_images'
223214
doctree_dir = tmp_path / 'doctrees'

0 commit comments

Comments
 (0)
0