Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

test(filesystem): assert header markers are stripped, not that '#' is absent

Saurav Panda0193edfb099c
diff --git a/tests/ci/infrastructure/test_filesystem.py b/tests/ci/infrastructure/test_filesystem.py
index c96c35294..a47d83a13 100644
--- a/tests/ci/infrastructure/test_filesystem.py
+++ b/tests/ci/infrastructure/test_filesystem.py
@@ -225,19 +225,24 @@ class TestFileSystem:
async def test_write_pdf_preserves_plain_text_angle_brackets(self, empty_filesystem):
"""PDF content should be rendered as plain text, not ReportLab markup."""
- lines = ['# Q&A: <b y vs 5', '## Section 2 & 3', '### Notes <i>', 'Comparison: 2 <b y & 5 > 4']
+ # (markdown source, text expected in the PDF)
+ headers = [
+ ('# Q&A: <b y vs 5', 'Q&A: <b y vs 5'),
+ ('## Section 2 & 3', 'Section 2 & 3'),
+ ('### Notes <i> #1', 'Notes <i> #1'),
+ ]
+ body = 'Comparison: 2 <b y & 5 > 4'
- result = await empty_filesystem.write_file('comparison.pdf', '\n\n'.join(lines))
+ result = await empty_filesystem.write_file('comparison.pdf', '\n\n'.join([source for source, _ in headers] + [body]))
assert result == 'Data written to file comparison.pdf successfully.'
pdf_path = empty_filesystem.data_dir / 'comparison.pdf'
extracted_text = '\n'.join(page.extract_text() or '' for page in PdfReader(pdf_path).pages)
- # Header markers are stripped, everything else survives verbatim
- assert 'Q&A: <b y vs 5' in extracted_text
- assert 'Section 2 & 3' in extracted_text
- assert 'Notes <i>' in extracted_text
- assert 'Comparison: 2 <b y & 5 > 4' in extracted_text
- assert '#' not in extracted_text
+ assert body in extracted_text
+ for source, rendered in headers:
+ # Only the leading header marker is stripped, everything else survives verbatim
+ assert rendered in extracted_text
+ assert source not in extracted_text
def test_filesystem_initialization(self, temp_filesystem):
"""Test FileSystem initialization with default files."""