Skip to content

Commit b32b1d7

Browse files
committed
test(rss): assert concurrent conversions keep every call-specific option
The concurrent-options regression test only pinned keep_data_uris, so it would still pass if only that option were threaded while another kept leaking. Add heading_style (atx vs underlined) and bullets ("+" vs "*") as additional dimensions and assert each conversion keeps all of its own options. Uses valid markdownify values: heading_style "atx"/"underlined" (not "setext", which markdownify silently ignores and would make the test pass for the wrong reason). Verified: the test fails on the pre-patch RssConverter (all three options leak to the other call) and passes on the patched one; full test_rss.py -> 165 passed; black --check clean.
1 parent e686a5d commit b32b1d7

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

‎packages/markitdown/tests/test_rss.py‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,44 @@ def _parse_content(self, content: str, **kwargs) -> str:
9797

9898
def test_concurrent_conversions_keep_call_specific_markdown_options() -> None:
9999
embedded = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///w=="
100-
feed = _feed_with_body("atom-content", f'<img src="{embedded}" alt="Pixel"/>')
100+
feed = _feed_with_body(
101+
"atom-content",
102+
f'<h2>Section</h2><ul><li>item</li></ul><img src="{embedded}" alt="Pixel"/>',
103+
)
101104
converter = _SynchronizedRssConverter()
102105
stream_info = StreamInfo(extension=".atom")
103106

104-
def convert(keep_data_uris: bool) -> str:
107+
def convert(keep_data_uris: bool, heading_style: str, bullets: str) -> str:
105108
return converter.convert(
106109
io.BytesIO(feed),
107110
stream_info,
108111
keep_data_uris=keep_data_uris,
112+
heading_style=heading_style,
113+
bullets=bullets,
109114
).markdown
110115

111116
with ThreadPoolExecutor(max_workers=2) as pool:
112-
kept = pool.submit(convert, True)
113-
truncated = pool.submit(convert, False)
117+
a = pool.submit(convert, True, "atx", "+")
118+
b = pool.submit(convert, False, "underlined", "*")
119+
120+
a_md = a.result()
121+
b_md = b.result()
122+
123+
# Dimensions are asserted together so a leak in any one of them fails the test,
124+
# not just keep_data_uris (see the PR review note about single-dimension coverage).
125+
126+
# keep_data_uris
127+
assert f"![Pixel]({embedded})" in a_md
128+
assert "![Pixel](data:image/gif;base64...)" in b_md
129+
130+
# heading_style: atx ("##") on A, setext/underlined on B
131+
assert "## Section" in a_md
132+
assert "## Section" not in b_md
133+
assert "Section\n------" in b_md
114134

115-
assert f"![Pixel]({embedded})" in kept.result()
116-
assert "![Pixel](data:image/gif;base64...)" in truncated.result()
135+
# bullets: "+" on A, "*" on B
136+
assert "+ item" in a_md
137+
assert "* item" in b_md and "+ item" not in b_md
117138

118139

119140
def test_atom_ignores_elements_from_other_namespaces() -> None:

0 commit comments

Comments
 (0)