From 13e895b9b0fa547d2f111cb0541bf4f895a1fea4 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 16 Oct 2025 18:00:46 -0700 Subject: [PATCH] test fix --- tests/llm_translation/base_llm_unit_tests.py | 14 ++++---- tests/llm_translation/fixtures/dummy.pdf | 36 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 tests/llm_translation/fixtures/dummy.pdf diff --git a/tests/llm_translation/base_llm_unit_tests.py b/tests/llm_translation/base_llm_unit_tests.py index 1419edaea42..26e82f215ea 100644 --- a/tests/llm_translation/base_llm_unit_tests.py +++ b/tests/llm_translation/base_llm_unit_tests.py @@ -1056,14 +1056,14 @@ class BaseLLMChatTest(ABC): @pytest.fixture def pdf_messages(self): import base64 + import os - import requests - - # URL of the file - url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" - - response = requests.get(url) - file_data = response.content + # Use local PDF file instead of external URL to avoid flaky tests + test_dir = os.path.dirname(__file__) + pdf_path = os.path.join(test_dir, "fixtures", "dummy.pdf") + + with open(pdf_path, "rb") as f: + file_data = f.read() encoded_file = base64.b64encode(file_data).decode("utf-8") url = f"data:application/pdf;base64,{encoded_file}" diff --git a/tests/llm_translation/fixtures/dummy.pdf b/tests/llm_translation/fixtures/dummy.pdf new file mode 100644 index 00000000000..f467e66f067 --- /dev/null +++ b/tests/llm_translation/fixtures/dummy.pdf @@ -0,0 +1,36 @@ +%PDF-1.4 +1 0 obj +<< /Type /Catalog /Pages 2 0 R >> +endobj +2 0 obj +<< /Type /Pages /Kids [3 0 R] /Count 1 >> +endobj +3 0 obj +<< /Type /Page /Parent 2 0 R /Resources 4 0 R /MediaBox [0 0 612 792] /Contents 5 0 R >> +endobj +4 0 obj +<< /Font << /F1 << /Type /Font /Subtype /Type1 /BaseFont /Helvetica >> >> >> +endobj +5 0 obj +<< /Length 44 >> +stream +BT +/F1 12 Tf +100 700 Td +(Test PDF File) Tj +ET +endstream +endobj +xref +0 6 +0000000000 65535 f +0000000009 00000 n +0000000058 00000 n +0000000115 00000 n +0000000214 00000 n +0000000293 00000 n +trailer +<< /Size 6 /Root 1 0 R >> +startxref +385 +%%EOF