fix(telegram): hard-cut fence splits when the closer cannot fit
Adaptive HTML limits can shrink max_len to the fence prefix size. Treat budget <= min_code_pos as a hard cut so the splitter still advances.
This commit is contained in:
1 parent
017a4946e2
commit
98d661775e
2 files changed
+36
-10
No files matched your search
@@ -268,6 +268,32 @@ def test_split_telegram_markdown_long_single_line_code_body() -> None:
|
||||
_assert_code_blocks_render_balanced(chunks)
|
||||
|
||||
|
||||
def test_split_telegram_markdown_tiny_limit_hard_cuts_fence_prefix() -> None:
|
||||
"""Adaptive HTML limits can shrink max_len to the fence+closer size."""
|
||||
body = "a" * 100
|
||||
content = f"```\n{body}"
|
||||
|
||||
chunks = _split_telegram_markdown(content, max_len=8)
|
||||
|
||||
assert chunks
|
||||
assert all(len(chunk) <= 8 for chunk in chunks)
|
||||
assert "".join(chunks).replace("```", "").replace("\n", "") == body
|
||||
|
||||
|
||||
def test_split_telegram_markdown_tiny_limit_with_early_body_newline() -> None:
|
||||
body = "a" * 100
|
||||
content = f"```\na\n{body}"
|
||||
|
||||
chunks = _split_telegram_markdown(content, max_len=8)
|
||||
|
||||
assert chunks
|
||||
assert all(len(chunk) <= 8 for chunk in chunks)
|
||||
plain = "".join(chunks).replace("```", "")
|
||||
assert "a" in plain
|
||||
assert plain.count("a") >= 100
|
||||
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_creates_separate_pools_with_proxy(monkeypatch) -> None:
|
||||
_FakeHTTPXRequest.clear()
|
||||
|
||||
Reference in new issue
Block a user