16
16
tinypages = Path (__file__ ).parent / 'data/tinypages'
17
17
18
18
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
-
30
19
def build_sphinx_html (source_dir , doctree_dir , html_dir , extra_args = None ):
31
20
# Build the pages with warnings turned into errors
32
21
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):
52
41
53
42
def test_tinypages (tmp_path ):
54
43
shutil .copytree (tinypages , tmp_path , dirs_exist_ok = True ,
55
- ignore = _ignore_build_artifacts )
44
+ ignore = shutil .ignore_patterns ('_build' , 'doctrees' ,
45
+ 'plot_directive' ))
56
46
html_dir = tmp_path / '_build' / 'html'
57
47
img_dir = html_dir / '_images'
58
48
doctree_dir = tmp_path / 'doctrees'
@@ -217,7 +207,8 @@ def test_plot_html_show_source_link_custom_basename(tmp_path):
217
207
218
208
def test_srcset_version (tmp_path ):
219
209
shutil .copytree (tinypages , tmp_path , dirs_exist_ok = True ,
220
- ignore = _ignore_build_artifacts )
210
+ ignore = shutil .ignore_patterns ('_build' , 'doctrees' ,
211
+ 'plot_directive' ))
221
212
html_dir = tmp_path / '_build' / 'html'
222
213
img_dir = html_dir / '_images'
223
214
doctree_dir = tmp_path / 'doctrees'
0 commit comments