Skip to content

Commit 945a6cb

Browse files
committed
tests(cli/search): Add test for invalid regex pattern error
Add test_compile_search_patterns_invalid_regex_raises to verify that compile_search_patterns() raises re.error when given an invalid regex pattern like "[invalid(". This ensures the re.error exception handling path in command_search() is properly tested.
1 parent 1c62752 commit 945a6cb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/cli/test_search.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,13 @@ def test_compile_search_patterns(
345345
assert bool(match) == should_match
346346

347347

348+
def test_compile_search_patterns_invalid_regex_raises() -> None:
349+
"""Invalid regex pattern raises re.error."""
350+
tokens = [SearchToken(fields=("name",), pattern="[invalid(")]
351+
with pytest.raises(re.error):
352+
compile_search_patterns(tokens)
353+
354+
348355
def test_extract_workspace_fields_basic(tmp_path: pathlib.Path) -> None:
349356
"""Extract fields from basic workspace file."""
350357
workspace = tmp_path / "test.yaml"

0 commit comments

Comments
 (0)