Skip to content

Commit 267d1c3

Browse files
committed
tests: respect chunking config constraints
1 parent 4df29ee commit 267d1c3

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

tests/unit/test_chunker.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_ast_chunking_python_preserves_top_level_blocks() -> None:
150150
chunking_strategy="ast",
151151
chunk_size=500,
152152
chunk_overlap=100,
153-
target_tokens=60,
153+
target_tokens=64,
154154
overlap_tokens=0,
155155
ast_overlap_lines=0,
156156
preserve_imports=0, # imports merge into the first block chunk
@@ -159,7 +159,7 @@ def test_ast_chunking_python_preserves_top_level_blocks() -> None:
159159
tok_cfg = TokenizationConfig(strategy="whitespace", normalize_unicode=False, lowercase=False)
160160
ch = Chunker(cfg, tok_cfg)
161161

162-
body_tokens = " ".join([f"tok{i}" for i in range(18)])
162+
body_tokens = " ".join([f"tok{i}" for i in range(45)])
163163
content = (
164164
"import os\nimport sys\n\n"
165165
"def foo():\n"
@@ -182,7 +182,7 @@ def test_ast_chunking_python_can_isolate_imports_when_enabled() -> None:
182182
chunking_strategy="ast",
183183
chunk_size=500,
184184
chunk_overlap=100,
185-
target_tokens=20,
185+
target_tokens=64,
186186
overlap_tokens=0,
187187
ast_overlap_lines=0,
188188
preserve_imports=1,
@@ -194,10 +194,10 @@ def test_ast_chunking_python_can_isolate_imports_when_enabled() -> None:
194194
content = (
195195
"import os\nimport sys\n\n"
196196
"def foo():\n"
197-
" # a a a a a a a a a a\n"
197+
" # " + " ".join(["a" for _i in range(90)]) + "\n"
198198
" return 1\n\n"
199199
"def bar():\n"
200-
" # b b b b b b b b b b\n"
200+
" # " + " ".join(["b" for _i in range(90)]) + "\n"
201201
" return 2\n"
202202
)
203203
chunks = ch.chunk_file("x.py", content)
@@ -213,7 +213,7 @@ def test_hybrid_chunking_falls_back_on_syntax_error() -> None:
213213
chunking_strategy="hybrid",
214214
chunk_size=500,
215215
chunk_overlap=100,
216-
target_tokens=16,
216+
target_tokens=64,
217217
overlap_tokens=4,
218218
min_chunk_chars=10,
219219
)
@@ -231,14 +231,14 @@ def test_ast_chunking_typescript_respects_top_level_brace_blocks() -> None:
231231
chunking_strategy="ast",
232232
chunk_size=500,
233233
chunk_overlap=100,
234-
target_tokens=40,
234+
target_tokens=64,
235235
overlap_tokens=0,
236236
min_chunk_chars=10,
237237
)
238238
tok_cfg = TokenizationConfig(strategy="whitespace", normalize_unicode=False, lowercase=False)
239239
ch = Chunker(cfg, tok_cfg)
240240

241-
toks = " ".join([f"w{i}" for i in range(18)])
241+
toks = " ".join([f"w{i}" for i in range(45)])
242242
content = (
243243
"export function foo() {\n"
244244
f" // {toks}\n"

0 commit comments

Comments
 (0)