Skip to content

Commit 515e171

Browse files
committed
Update PDF conversion tests to include mimetype in StreamInfo
1 parent 6246ce1 commit 515e171

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

packages/markitdown/tests/test_pdf_memory.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ def test_page_close_called_on_every_page(self):
101101
buf = io.BytesIO(b"fake pdf content")
102102
from markitdown import StreamInfo
103103

104-
md.convert_stream(buf, stream_info=StreamInfo(extension=".pdf"))
104+
md.convert_stream(
105+
buf,
106+
stream_info=StreamInfo(extension=".pdf", mimetype="application/pdf"),
107+
)
105108

106109
# page.close() must be called on ALL pages
107110
for i, page in enumerate(pages):
@@ -132,7 +135,10 @@ def test_plain_text_pdf_falls_back_to_pdfminer(self):
132135
buf = io.BytesIO(b"fake pdf content")
133136
from markitdown import StreamInfo
134137

135-
result = md.convert_stream(buf, stream_info=StreamInfo(extension=".pdf"))
138+
result = md.convert_stream(
139+
buf,
140+
stream_info=StreamInfo(extension=".pdf", mimetype="application/pdf"),
141+
)
136142

137143
# pdfminer should be used for the final text extraction
138144
assert mock_pdfminer.high_level.extract_text.called, (
@@ -158,7 +164,10 @@ def test_plain_text_pdf_still_closes_all_pages(self):
158164
buf = io.BytesIO(b"fake pdf content")
159165
from markitdown import StreamInfo
160166

161-
md.convert_stream(buf, stream_info=StreamInfo(extension=".pdf"))
167+
md.convert_stream(
168+
buf,
169+
stream_info=StreamInfo(extension=".pdf", mimetype="application/pdf"),
170+
)
162171

163172
for i, page in enumerate(pages):
164173
assert (
@@ -189,7 +198,10 @@ def test_mixed_pdf_uses_form_extraction_per_page(self):
189198
buf = io.BytesIO(b"fake pdf content")
190199
from markitdown import StreamInfo
191200

192-
result = md.convert_stream(buf, stream_info=StreamInfo(extension=".pdf"))
201+
result = md.convert_stream(
202+
buf,
203+
stream_info=StreamInfo(extension=".pdf", mimetype="application/pdf"),
204+
)
193205

194206
# All pages should have close() called
195207
for i, page in enumerate(pages):
@@ -220,7 +232,10 @@ def test_only_one_pdfplumber_open_call(self):
220232
buf = io.BytesIO(b"fake pdf content")
221233
from markitdown import StreamInfo
222234

223-
md.convert_stream(buf, stream_info=StreamInfo(extension=".pdf"))
235+
md.convert_stream(
236+
buf,
237+
stream_info=StreamInfo(extension=".pdf", mimetype="application/pdf"),
238+
)
224239

225240
assert mock_pdfplumber.open.call_count == 1, (
226241
f"Expected 1 pdfplumber.open call (single pass), "

0 commit comments

Comments
 (0)