From d1fd6eb79e7949aa802d8849aa9ce311be79f2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:27:41 +0200 Subject: [PATCH 1/6] Fix `test_search.py` with long-word splitting --- tests/test_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_search.py b/tests/test_search.py index f94ae987bb7..b6b72bcfff7 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -144,7 +144,7 @@ def test_stemmer(app: SphinxTestApp) -> None: searchindex = load_searchindex(app.outdir / 'searchindex.js') print(searchindex) assert is_registered_term(searchindex, 'findthisstemmedkey') - assert is_registered_term(searchindex, 'intern') + assert is_registered_term(searchindex, 'internat') @pytest.mark.sphinx('html', testroot='search') From 469773d068aadc85c6a1dda17b9db0334cca8db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:30:08 +0200 Subject: [PATCH 2/6] probably more fixes --- tests/roots/test-search/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/roots/test-search/index.rst b/tests/roots/test-search/index.rst index b38fd0271f6..c618633c345 100644 --- a/tests/roots/test-search/index.rst +++ b/tests/roots/test-search/index.rst @@ -19,6 +19,7 @@ International .. tip:: :class: no-search + bat cat .. toctree:: From 6f824176535f4b873cbdfe7c9e99d5f23262a857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:39:03 +0200 Subject: [PATCH 3/6] better fix --- tests/test_search.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_search.py b/tests/test_search.py index b6b72bcfff7..b55788091b2 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -76,6 +76,14 @@ def is_registered_term(index: Any, keyword: str) -> bool: return index['terms'].get(keyword, []) != [] +def is_registered_prefix(index: Any, prefix: str) -> bool: + terms = index["terms"] + for key, value in terms.items(): + if key.startswith(prefix) and value != []: + return True + return False + + FILE_CONTENTS = """\ section_title ============= @@ -144,7 +152,7 @@ def test_stemmer(app: SphinxTestApp) -> None: searchindex = load_searchindex(app.outdir / 'searchindex.js') print(searchindex) assert is_registered_term(searchindex, 'findthisstemmedkey') - assert is_registered_term(searchindex, 'internat') + assert is_registered_prefix(searchindex, 'intern') @pytest.mark.sphinx('html', testroot='search') From c638919f7ea87104c25a77508e15163cfb466b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:40:31 +0200 Subject: [PATCH 4/6] fixup --- tests/test_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_search.py b/tests/test_search.py index b55788091b2..57cf310f036 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -77,7 +77,7 @@ def is_registered_term(index: Any, keyword: str) -> bool: def is_registered_prefix(index: Any, prefix: str) -> bool: - terms = index["terms"] + terms = index['terms'] for key, value in terms.items(): if key.startswith(prefix) and value != []: return True From 55f34f425547c521eaa982c1f01ee87e7fbdc4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:41:09 +0200 Subject: [PATCH 5/6] fixup --- tests/test_search.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_search.py b/tests/test_search.py index 57cf310f036..3643794f8b8 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -78,10 +78,10 @@ def is_registered_term(index: Any, keyword: str) -> bool: def is_registered_prefix(index: Any, prefix: str) -> bool: terms = index['terms'] - for key, value in terms.items(): - if key.startswith(prefix) and value != []: - return True - return False + return any( + key.startswith(prefix) and value != [] + for key, value in terms.items() + ) FILE_CONTENTS = """\ From 6510fb585219bc218a32f7d520fa40a540828aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:41:34 +0200 Subject: [PATCH 6/6] ruff --- tests/test_search.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_search.py b/tests/test_search.py index 3643794f8b8..64ec4670085 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -78,10 +78,7 @@ def is_registered_term(index: Any, keyword: str) -> bool: def is_registered_prefix(index: Any, prefix: str) -> bool: terms = index['terms'] - return any( - key.startswith(prefix) and value != [] - for key, value in terms.items() - ) + return any(k.startswith(prefix) and v != [] for k, v in terms.items()) FILE_CONTENTS = """\