Files
DeepTutor/tests/partners/test_markdown_table_empty_cells.py
Bingxi Zhao (Frank) 1667d070ec refactor(partners): unify markdown table row splitting across channels
#679/#682/#683 each fixed markdown-table cell handling in one channel, but
Slack (convert_markdown_table_to_labeled_rows) and Telegram (_render_table_box)
still split rows with str.strip("|"), which collapses leading/trailing empty
cells and shifts every column — only Feishu (#683) had the correct split.

Extract split_markdown_table_row as the single primitive and route Slack,
Telegram, and Feishu through it: fixes the same class of bug in all three and
removes three near-duplicate row splitters. Slack's separator-row detection now
reuses is_markdown_table_separator_row instead of an ad-hoc regex.

Also fixes the #679 helpers-import ordering and formats the #679/#683 test
files that squash-merge did not run through ruff format.
2026-07-24 16:19:35 +08:00

16 lines
656 B
Python

"""Empty markdown table cells must still appear in labeled-row conversion."""
from __future__ import annotations
from deeptutor.partners.helpers import convert_markdown_table_to_labeled_rows
def test_empty_cells_kept_in_converted_table() -> None:
table = "| Name | Score | Note |\n| --- | --- | --- |\n| Alice | | ok |\n| Bob | 10 | |\n"
out = convert_markdown_table_to_labeled_rows(table)
assert out.count("**Name**:") == 2
assert out.count("**Score**:") == 2
assert out.count("**Note**:") == 2
assert "**Score**: " in out # Alice empty score kept
assert out.endswith("**Note**: ") or "**Note**: " in out.split("\n")[1]