diff --git a/tests/test_search.py b/tests/test_search.py index a2b01c17b6b..3687911e488 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -13,7 +13,11 @@ from tests.utils import TESTS_ROOT -JAVASCRIPT_TEST_ROOTS = list((TESTS_ROOT / 'js' / 'roots').iterdir()) +JAVASCRIPT_TEST_ROOTS = [ + directory + for directory in (TESTS_ROOT / 'js' / 'roots').iterdir() + if (directory / 'conf.py').exists() +] class DummyEnvironment: diff --git a/utils/generate_js_fixtures.py b/utils/generate_js_fixtures.py index 37e844f1a80..34c6fbdcdba 100755 --- a/utils/generate_js_fixtures.py +++ b/utils/generate_js_fixtures.py @@ -1,11 +1,16 @@ #!/usr/bin/env python3 +import shutil import subprocess from pathlib import Path SPHINX_ROOT = Path(__file__).resolve().parent.parent TEST_JS_FIXTURES = SPHINX_ROOT / 'tests' / 'js' / 'fixtures' -TEST_JS_ROOTS = SPHINX_ROOT / 'tests' / 'js' / 'roots' +TEST_JS_ROOTS = [ + directory + for directory in (SPHINX_ROOT / 'tests' / 'js' / 'roots').iterdir() + if (directory / 'conf.py').exists() +] def build(srcdir: Path) -> None: @@ -20,7 +25,7 @@ def build(srcdir: Path) -> None: subprocess.run(cmd, check=True, capture_output=True) -for directory in TEST_JS_ROOTS.iterdir(): +for directory in TEST_JS_ROOTS: searchindex = directory / '_build' / 'searchindex.js' destination = TEST_JS_FIXTURES / directory.name / 'searchindex.js' @@ -28,7 +33,7 @@ def build(srcdir: Path) -> None: build(directory) print('done') - print(f'Moving {searchindex} to {destination} ... ', end='') + print(f'Copying {searchindex} to {destination} ... ', end='') destination.parent.mkdir(exist_ok=True) - searchindex.replace(destination) + shutil.copy2(searchindex, destination) print('done')