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
+
19
30
def build_sphinx_html (source_dir , doctree_dir , html_dir , extra_args = None ):
20
31
# Build the pages with warnings turned into errors
21
32
extra_args = [] if extra_args is None else extra_args
@@ -40,7 +51,8 @@ def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
40
51
41
52
42
53
def test_tinypages (tmp_path ):
43
- shutil .copytree (tinypages , tmp_path , dirs_exist_ok = True )
54
+ shutil .copytree (tinypages , tmp_path , dirs_exist_ok = True ,
55
+ ignore = _ignore_build_artifacts )
44
56
html_dir = tmp_path / '_build' / 'html'
45
57
img_dir = html_dir / '_images'
46
58
doctree_dir = tmp_path / 'doctrees'
@@ -204,11 +216,13 @@ def test_plot_html_show_source_link_custom_basename(tmp_path):
204
216
205
217
206
218
def test_srcset_version (tmp_path ):
219
+ shutil .copytree (tinypages , tmp_path , dirs_exist_ok = True ,
220
+ ignore = _ignore_build_artifacts )
207
221
html_dir = tmp_path / '_build' / 'html'
208
222
img_dir = html_dir / '_images'
209
223
doctree_dir = tmp_path / 'doctrees'
210
224
211
- build_sphinx_html (tinypages , doctree_dir , html_dir ,
225
+ build_sphinx_html (tmp_path , doctree_dir , html_dir ,
212
226
extra_args = ['-D' , 'plot_srcset=2x' ])
213
227
214
228
def plot_file (num , suff = '' ):
0 commit comments